bestcomm: no need to free when kzalloc fail
PATCH 1/1 bestcomm: no need to free when kzalloc fail
From: Libo Chen <[email protected]>
There is no need to free bcom_eng if kzalloc fail
--- drivers/dma/bestcomm/bestcomm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/dma/bestcomm/bestcomm.c +2 -1
@@ -400,7 +400,7 @@ static int mpc52xx_bcom_probe(struct platform_device *op) printk(KERN_ERR DRIVER_NAME ": " "Can't allocate state structure\n"); rv = -ENOMEM ; - goto error_sramclean; + goto error_kzalloc; }/* Save the node */
@@ -449,6 +449,7 @@ error_release:release_mem_region (res_bcom.start,sizeof (struct mpc52xx_sdma )); error_sramclean:kfree (bcom_eng); +error_kzalloc:bcom_sram_cleanup (); error_ofput:of_node_put (op->dev.of_node);
Signature · 1 line
1.8.1.2
ping...
Quoted 31 lines · On 2013/5/5 16:38, [email protected] wrote:
From: Libo Chen <[email protected]>
There is no need to free
bcom_engif kzalloc failSigned-off-by Libo Chen <[email protected]>--- drivers/dma/bestcomm/bestcomm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/dma/bestcomm/bestcomm.c +2
-1@@ -400,7 +400,7 @@ static int mpc52xx_bcom_probe(struct platform_device *op) printk(KERN_ERR DRIVER_NAME ": " "Can't allocate state structure\n"); rv = -ENOMEM ; - goto error_sramclean; + goto error_kzalloc; }/* Save the node */ @@ -449,6 +449,7 @@ error_release:release_mem_region (res_bcom.start,sizeof (struct mpc52xx_sdma )); error_sramclean:kfree (bcom_eng); +error_kzalloc:bcom_sram_cleanup (); error_ofput:of_node_put (op->dev.of_node);
Quoted 8 lines · Libo Chen
ping...
Quoted 4 lines · On 2013/5/5 16:38, [email protected] wrote:
From: Libo Chen <[email protected]>
There is no need to free
bcom_engif kzalloc fail
kfree(NULL) is fine. We gain nothing from this patch, and it even adds one more line to the code, so just drop thi patch.
Quoted 31 lines
Quoted 20 lines
Signed-off-by Libo Chen <[email protected]>--- drivers/dma/bestcomm/bestcomm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/dma/bestcomm/bestcomm.c +1
-1@@ -400,7 +400,7 @@ static int mpc52xx_bcom_probe(struct platform_device *op) printk(KERN_ERR DRIVER_NAME ": " "Can't allocate state structure\n"); rv = -ENOMEM ; - goto error_sramclean; + goto error_kzalloc; }/* Save the node */ drivers/dma/bestcomm/bestcomm.c error_release: · line 455
Quoted 7 lines
drivers/dma/bestcomm/bestcomm.c +1
-0@@ -449,6 +449,7 @@ error_release:release_mem_region (res_bcom.start,sizeof (struct mpc52xx_sdma )); error_sramclean:kfree (bcom_eng); +error_kzalloc:bcom_sram_cleanup (); error_ofput:of_node_put (op->dev.of_node);.
Quoted 4 lines · Li Zefan
Quoted 3 lines · Libo Chen
ping...
Quoted 9 lines
Quoted 5 lines · On 2013/5/5 16:38, [email protected] wrote:
Quoted 4 lines
From: Libo Chen <[email protected]>
There is no need to free
bcom_engif kzalloc failkfree(NULL) is fine. We gain nothing from this patch, and it even adds one more line to the code, so just drop thi patch.
yes, no bad will happen
thanks,
Libo
Quoted 35 lines
Quoted 17 lines
Quoted 17 lines
Signed-off-by Libo Chen <[email protected]>--- drivers/dma/bestcomm/bestcomm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/dma/bestcomm/bestcomm.c +1
-1@@ -400,7 +400,7 @@ static int mpc52xx_bcom_probe(struct platform_device *op) printk(KERN_ERR DRIVER_NAME ": " "Can't allocate state structure\n"); rv = -ENOMEM ; - goto error_sramclean; + goto error_kzalloc; }Quoted 14 lines
drivers/dma/bestcomm/bestcomm.c error_release: · line 455
Quoted 10 lines
drivers/dma/bestcomm/bestcomm.c +1
-0/* Save the node */ @@ -449,6 +449,7 @@ error_release:release_mem_region (res_bcom.start,sizeof (struct mpc52xx_sdma )); error_sramclean:kfree (bcom_eng); +error_kzalloc:bcom_sram_cleanup (); error_ofput:of_node_put (op->dev.of_node);.
.
Quoted 1 line · Libo Chen
ping...
This is pointless. We routinely avoid adding such crap by having the various free(...) routines cope with NULL. You just need to make sure you are indeed NULL in the error case.
Ben.
Quoted 33 lines · On 2013/5/5 16:38, [email protected] wrote:
Quoted 31 lines
From: Libo Chen <[email protected]>
There is no need to free
bcom_engif kzalloc failSigned-off-by Libo Chen <[email protected]>--- drivers/dma/bestcomm/bestcomm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/dma/bestcomm/bestcomm.c +2
-1@@ -400,7 +400,7 @@ static int mpc52xx_bcom_probe(struct platform_device *op) printk(KERN_ERR DRIVER_NAME ": " "Can't allocate state structure\n"); rv = -ENOMEM ; - goto error_sramclean; + goto error_kzalloc; }/* Save the node */ @@ -449,6 +449,7 @@ error_release:release_mem_region (res_bcom.start,sizeof (struct mpc52xx_sdma )); error_sramclean:kfree (bcom_eng); +error_kzalloc:bcom_sram_cleanup (); error_ofput:of_node_put (op->dev.of_node);
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 1 line · Libo Chen
ping...
This is pointless. We routinely avoid adding such crap by having the various free(...) routines cope with NULL. You just need to make sure you are indeed NULL in the error case.
Ben.
thanks,
Libo
Quoted 39 lines
Quoted 23 lines · On 2013/5/5 16:38, [email protected] wrote:
Quoted 21 lines
From: Libo Chen <[email protected]>
There is no need to free
bcom_engif kzalloc failSigned-off-by Libo Chen <[email protected]>--- drivers/dma/bestcomm/bestcomm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/dma/bestcomm/bestcomm.c +1
-1@@ -400,7 +400,7 @@ static int mpc52xx_bcom_probe(struct platform_device *op) printk(KERN_ERR DRIVER_NAME ": " "Can't allocate state structure\n"); rv = -ENOMEM ; - goto error_sramclean; + goto error_kzalloc; }Quoted 11 lines
drivers/dma/bestcomm/bestcomm.c error_release: · line 455
Quoted 10 lines
drivers/dma/bestcomm/bestcomm.c +1
-0/* Save the node */ @@ -449,6 +449,7 @@ error_release:release_mem_region (res_bcom.start,sizeof (struct mpc52xx_sdma )); error_sramclean:kfree (bcom_eng); +error_kzalloc:bcom_sram_cleanup (); error_ofput:of_node_put (op->dev.of_node);.