All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] leds: lm3556: Don't call kfree for the memory allocated by devm_kzalloc
@ 2012-04-22 14:57 Axel Lin
  0 siblings, 0 replies; only message in thread
From: Axel Lin @ 2012-04-22 14:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Geon Si Jeong, Woogyom Kim, Richard Purdie, Andrew Morton

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>
---
 drivers/leds/leds-lm3556.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/leds/leds-lm3556.c b/drivers/leds/leds-lm3556.c
index cc0abbc..15a5acd 100644
--- a/drivers/leds/leds-lm3556.c
+++ b/drivers/leds/leds-lm3556.c
@@ -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;
 }
 
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-04-22 14:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-22 14:57 [PATCH] leds: lm3556: Don't call kfree for the memory allocated by devm_kzalloc Axel Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.