Input: wm831x-on - Convert to devm_kzalloc()
Subsystems (3)
PATCH 1/1 Input: wm831x-on - Convert to devm_kzalloc()
Saves a small amount of code and reduces the potential for leaks.
Signed-off-by Mark Brown <[email protected]>
--- drivers/input/misc/wm831x-on.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/input/misc/wm831x-on.c +2 -3
@@ -76,7 +76,8 @@ static int __devinit wm831x_on_probe(struct platform_device *pdev)int irq =platform_get_irq (pdev,0 );int ret; - wm831x_on =kzalloc (sizeof (struct wm831x_on ),GFP_KERNEL ); + wm831x_on =devm_kzalloc (&pdev->dev,sizeof (struct wm831x_on ), +GFP_KERNEL );if (!wm831x_on) {dev_err (&pdev->dev,"Can't allocate data\n" );return -ENOMEM ;
@@ -120,7 +121,6 @@ err_irq: err_input_dev:input_free_device (wm831x_on->dev); err: -kfree (wm831x_on);return ret; }
@@ -132,7 +132,6 @@ static int __devexit wm831x_on_remove(struct platform_device *pdev)free_irq (irq, wm831x_on);cancel_delayed_work_sync (&wm831x_on->work);input_unregister_device (wm831x_on->dev); -kfree (wm831x_on);return 0 ; }
Signature · 1 line
1.7.7.3
Quoted 1 line
Saves a small amount of code and reduces the potential for leaks.
Shouldn't you still be kind and free the memory anyway?
M
Quoted 36 lines
Signed-off-by Mark Brown <[email protected]>--- drivers/input/misc/wm831x-on.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/drivers/input/misc/wm831x-on.cindex 47f18d6..aee53fb 100644drivers/input/misc/wm831x-on.c +2
-3@@ -76,7 +76,8 @@ static int __devinit wm831x_on_probe(struct platform_device *pdev) int irq = platform_get_irq(pdev, 0);int ret; - wm831x_on =kzalloc (sizeof (struct wm831x_on ),GFP_KERNEL ); + wm831x_on =devm_kzalloc (&pdev->dev,sizeof (struct wm831x_on ), +GFP_KERNEL );if (!wm831x_on) {dev_err (&pdev->dev,"Can't allocate data\n" );return -ENOMEM ;@@ -120,7 +121,6 @@ err_irq: err_input_dev:input_free_device (wm831x_on->dev); err: -kfree (wm831x_on);return ret; }@@ -132,7 +132,6 @@ static int __devexit wm831x_on_remove(struct platform_device *pdev) free_irq(irq, wm831x_on);cancel_delayed_work_sync (&wm831x_on->work);input_unregister_device (wm831x_on->dev); -kfree (wm831x_on);return 0 ; }
Quoted 3 lines · Marek Vasut
Quoted 1 line
Saves a small amount of code and reduces the potential for leaks.
Shouldn't you still be kind and free the memory anyway?
There doesn't seem to be much point if it's going to be freed immediately anyway and half the point of the helpers is to avoid having to write the cleanup code.