]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
leds: lm3556: don't call kfree for the memory allocated by devm_kzalloc
authorAxel Lin <axel.lin@gmail.com>
Thu, 3 May 2012 05:44:24 +0000 (15:44 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 3 May 2012 05:46:47 +0000 (15:46 +1000)
The devm_* functions eliminate the need for manual resource releasing
and simplify error handling. Resources allocated by devm_* are freed
automatically on driver detach.

Thus adding kfree calls here will introduce double free bug.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Cc: Geon Si Jeong <gshark.jeong@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/leds/leds-lm3556.c

index cc0abbcfee1bd6b4b55eb6101516fd6affa7ae90..15a5acdb77ef8bb62def9676c9f5d8f5b138481f 100644 (file)
@@ -360,9 +360,8 @@ static int lm3556_probe(struct i2c_client *client,
                return -ENODATA;
        }
 
-       chip =
-           devm_kzalloc(&client->dev, sizeof(struct lm3556_chip_data),
-                        GFP_KERNEL);
+       chip = devm_kzalloc(&client->dev, sizeof(struct lm3556_chip_data),
+                           GFP_KERNEL);
        if (!chip)
                return -ENOMEM;
 
@@ -416,7 +415,6 @@ err_create_torch_file:
 err_create_flash_file:
 err_chip_init:
        i2c_set_clientdata(client, NULL);
-       kfree(chip);
        return err;
 }
 
@@ -430,7 +428,6 @@ static int lm3556_remove(struct i2c_client *client)
        led_classdev_unregister(&chip->cdev_flash);
        lm3556_write_reg(client, REG_ENABLE, 0);
 
-       kfree(chip);
        return 0;
 }