Commit f5ae79e9 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] zoran: memleak fixes

From: Ronald Bultje <rbultje@ronald.bitfreak.net>

This patch fixes several memleaks in error cases when the setup of i2c
client drivers for video encoders/decoders fails. We forgot to free some
memory in various places. This was noticed by Francois Romieu.
parent d6f459bc
......@@ -442,6 +442,7 @@ adv7170_detect_client (struct i2c_adapter *adapter,
dname = adv7171_name;
} else {
/* We should never get here!!! */
kfree(client);
return 0;
}
snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
......@@ -449,6 +450,7 @@ adv7170_detect_client (struct i2c_adapter *adapter,
encoder = kmalloc(sizeof(struct adv7170), GFP_KERNEL);
if (encoder == NULL) {
kfree(client);
return -ENOMEM;
}
memset(encoder, 0, sizeof(struct adv7170));
......
......@@ -463,6 +463,7 @@ adv7175_detect_client (struct i2c_adapter *adapter,
dname = adv7176_name;
} else {
/* We should never get here!!! */
kfree(client);
return 0;
}
snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
......@@ -470,6 +471,7 @@ adv7175_detect_client (struct i2c_adapter *adapter,
encoder = kmalloc(sizeof(struct adv7175), GFP_KERNEL);
if (encoder == NULL) {
kfree(client);
return -ENOMEM;
}
memset(encoder, 0, sizeof(struct adv7175));
......
......@@ -341,6 +341,7 @@ bt856_detect_client (struct i2c_adapter *adapter,
encoder = kmalloc(sizeof(struct bt856), GFP_KERNEL);
if (encoder == NULL) {
kfree(client);
return -ENOMEM;
}
memset(encoder, 0, sizeof(struct bt856));
......
......@@ -995,6 +995,8 @@ saa7114_detect_client (struct i2c_adapter *adapter,
KERN_ERR
"%s_attach: init error %d at stage %d, leaving attach.\n",
I2C_NAME(client), i, err[i]);
kfree(decoder);
kfree(client);
return 0;
}
}
......@@ -1022,6 +1024,8 @@ saa7114_detect_client (struct i2c_adapter *adapter,
KERN_ERR
"%s_attach: init error %d at stage %d, leaving attach.\n",
I2C_NAME(client), i, err[i]);
kfree(decoder);
kfree(client);
return 0;
}
}
......@@ -1068,6 +1072,8 @@ saa7114_detect_client (struct i2c_adapter *adapter,
KERN_ERR
"%s_attach: init error %d at stage %d, leaving attach.\n",
I2C_NAME(client), i, err[i]);
kfree(decoder);
kfree(client);
return 0;
}
}
......@@ -1107,6 +1113,8 @@ saa7114_detect_client (struct i2c_adapter *adapter,
KERN_ERR
"%s_attach: init error %d at stage %d, leaving attach.\n",
I2C_NAME(client), i, err[i]);
kfree(decoder);
kfree(client);
return 0;
}
}
......@@ -1127,6 +1135,8 @@ saa7114_detect_client (struct i2c_adapter *adapter,
KERN_ERR
"%s_attach: init error %d at stage %d, leaving attach.\n",
I2C_NAME(client), i, err[i]);
kfree(decoder);
kfree(client);
return 0;
}
}
......
......@@ -434,6 +434,7 @@ saa7185_detect_client (struct i2c_adapter *adapter,
encoder = kmalloc(sizeof(struct saa7185), GFP_KERNEL);
if (encoder == NULL) {
kfree(client);
return -ENOMEM;
}
memset(encoder, 0, sizeof(struct saa7185));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment