Re: [PATCH] w1: Add 1-wire slave device driver for DS28E04-100

From: Markus Franke
Date: Fri May 11 2012 - 02:15:40 EST


Dear Andrew,

thanks for the feedback.

Am 11.05.2012 01:22, schrieb Andrew Morton:

> On Fri, 11 May 2012 00:57:58 +0200
> Markus Franke <markus.franke@xxxxxxxxxxxxxxxxxxxx> wrote:
>
>> +static int w1_f1C_add_slave(struct w1_slave *sl)
>> +{
>> + int err = 0;
>> + int i;
>> + struct w1_f1C_data *data = NULL;
>> +
>> + if (w1_enable_crccheck) {
>> + data = kzalloc(sizeof(struct w1_f1C_data), GFP_KERNEL);
>> + if (!data)
>> + return -ENOMEM;
>> + sl->family_data = data;
>> + }
>> +
>> + /* create binary sysfs attributes */
>> + for (i = 0; i < NB_SYSFS_BIN_FILES && !err; ++i)
>> + err = sysfs_create_bin_file(
>> + &sl->dev.kobj, &(w1_f1C_bin_attr[i]));
>> +
>> + if (err)
>> + goto out;
>
> If this goto is taken, we will leak 0..i sysfs files.


That's indeed the case. :-(

>> + /* create device attributes */
>> + err = device_create_file(&sl->dev, &dev_attr_crccheck);
>> +
>> + if (err) {
>> + /* remove binary sysfs attributes */
>> + for (i = 0; i < NB_SYSFS_BIN_FILES; ++i)
>> + sysfs_remove_bin_file(
>> + &sl->dev.kobj, &(w1_f1C_bin_attr[i]));
>> + }
>> +
>> +out:
>> + if (err) {
>> + if (w1_enable_crccheck)
>> + kfree(data);
>
> kfree(NULL) is legal - the w1_enable_crccheck test can be removed.


Ok, I'll fix this for the next (hopefully final) version of the patch.

Best regards,
Markus Franke
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/