* [PATCH] bestcomm: no need to free when kzalloc fail
@ 2013-05-05 8:38 chenlibo.3
2013-05-22 4:49 ` Libo Chen
0 siblings, 1 reply; 6+ messages in thread
From: chenlibo.3 @ 2013-05-05 8:38 UTC (permalink / raw)
To: grant.likely, rob.herring; +Cc: linux-kernel, devicetree-discuss, Libo Chen
From: Libo Chen <libo.chen@huawei.com>
There is no need to free bcom_eng if kzalloc fail
Signed-off-by: Libo Chen <libo.chen@huawei.com>
---
drivers/dma/bestcomm/bestcomm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/bestcomm/bestcomm.c b/drivers/dma/bestcomm/bestcomm.c
index a8c2e29..300ee2d 100644
--- a/drivers/dma/bestcomm/bestcomm.c
+++ b/drivers/dma/bestcomm/bestcomm.c
@@ -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);
--
1.8.1.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] bestcomm: no need to free when kzalloc fail
2013-05-05 8:38 [PATCH] bestcomm: no need to free when kzalloc fail chenlibo.3
@ 2013-05-22 4:49 ` Libo Chen
2013-05-22 4:58 ` Li Zefan
2013-05-22 6:06 ` Benjamin Herrenschmidt
0 siblings, 2 replies; 6+ messages in thread
From: Libo Chen @ 2013-05-22 4:49 UTC (permalink / raw)
To: vinod.koul, grant.likely, rob.herring, Andrew Morton
Cc: linux-kernel, devicetree-discuss, Libo Chen, agust, phdm, benh,
Li Zefan
ping...
On 2013/5/5 16:38, chenlibo.3@gmail.com wrote:
> From: Libo Chen <libo.chen@huawei.com>
>
> There is no need to free bcom_eng if kzalloc fail
>
> Signed-off-by: Libo Chen <libo.chen@huawei.com>
> ---
> drivers/dma/bestcomm/bestcomm.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/bestcomm/bestcomm.c b/drivers/dma/bestcomm/bestcomm.c
> index a8c2e29..300ee2d 100644
> --- a/drivers/dma/bestcomm/bestcomm.c
> +++ b/drivers/dma/bestcomm/bestcomm.c
> @@ -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);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] bestcomm: no need to free when kzalloc fail
2013-05-22 4:49 ` Libo Chen
@ 2013-05-22 4:58 ` Li Zefan
2013-05-22 6:03 ` Libo Chen
2013-05-22 6:06 ` Benjamin Herrenschmidt
1 sibling, 1 reply; 6+ messages in thread
From: Li Zefan @ 2013-05-22 4:58 UTC (permalink / raw)
To: Libo Chen
Cc: vinod.koul, grant.likely, rob.herring, Andrew Morton,
linux-kernel, devicetree-discuss, Libo Chen, agust, phdm, benh
On 2013/5/22 12:49, Libo Chen wrote:
>
> ping...
>
> On 2013/5/5 16:38, chenlibo.3@gmail.com wrote:
>> From: Libo Chen <libo.chen@huawei.com>
>>
>> There is no need to free bcom_eng if 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.
>> Signed-off-by: Libo Chen <libo.chen@huawei.com>
>> ---
>> drivers/dma/bestcomm/bestcomm.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/dma/bestcomm/bestcomm.c b/drivers/dma/bestcomm/bestcomm.c
>> index a8c2e29..300ee2d 100644
>> --- a/drivers/dma/bestcomm/bestcomm.c
>> +++ b/drivers/dma/bestcomm/bestcomm.c
>> @@ -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);
>>
>
>
> .
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] bestcomm: no need to free when kzalloc fail
2013-05-22 4:58 ` Li Zefan
@ 2013-05-22 6:03 ` Libo Chen
0 siblings, 0 replies; 6+ messages in thread
From: Libo Chen @ 2013-05-22 6:03 UTC (permalink / raw)
To: Li Zefan
Cc: vinod.koul, grant.likely, rob.herring, Andrew Morton,
linux-kernel, devicetree-discuss, Libo Chen, agust, phdm, benh
On 2013/5/22 12:58, Li Zefan wrote:
> On 2013/5/22 12:49, Libo Chen wrote:
>>
>> ping...
>>
>> On 2013/5/5 16:38, chenlibo.3@gmail.com wrote:
>>> From: Libo Chen <libo.chen@huawei.com>
>>>
>>> There is no need to free bcom_eng if 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.
>
yes, no bad will happen
thanks,
Libo
>>> Signed-off-by: Libo Chen <libo.chen@huawei.com>
>>> ---
>>> drivers/dma/bestcomm/bestcomm.c | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/dma/bestcomm/bestcomm.c b/drivers/dma/bestcomm/bestcomm.c
>>> index a8c2e29..300ee2d 100644
>>> --- a/drivers/dma/bestcomm/bestcomm.c
>>> +++ b/drivers/dma/bestcomm/bestcomm.c
>>> @@ -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);
>>>
>>
>>
>> .
>>
>
>
> .
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] bestcomm: no need to free when kzalloc fail
2013-05-22 4:49 ` Libo Chen
2013-05-22 4:58 ` Li Zefan
@ 2013-05-22 6:06 ` Benjamin Herrenschmidt
2013-05-22 6:35 ` Libo Chen
1 sibling, 1 reply; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2013-05-22 6:06 UTC (permalink / raw)
To: Libo Chen
Cc: vinod.koul, grant.likely, rob.herring, Andrew Morton,
linux-kernel, devicetree-discuss, Libo Chen, agust, phdm,
Li Zefan
On Wed, 2013-05-22 at 12:49 +0800, Libo Chen wrote:
> 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.
> On 2013/5/5 16:38, chenlibo.3@gmail.com wrote:
> > From: Libo Chen <libo.chen@huawei.com>
> >
> > There is no need to free bcom_eng if kzalloc fail
> >
> > Signed-off-by: Libo Chen <libo.chen@huawei.com>
> > ---
> > drivers/dma/bestcomm/bestcomm.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/dma/bestcomm/bestcomm.c b/drivers/dma/bestcomm/bestcomm.c
> > index a8c2e29..300ee2d 100644
> > --- a/drivers/dma/bestcomm/bestcomm.c
> > +++ b/drivers/dma/bestcomm/bestcomm.c
> > @@ -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);
> >
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] bestcomm: no need to free when kzalloc fail
2013-05-22 6:06 ` Benjamin Herrenschmidt
@ 2013-05-22 6:35 ` Libo Chen
0 siblings, 0 replies; 6+ messages in thread
From: Libo Chen @ 2013-05-22 6:35 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: vinod.koul, grant.likely, rob.herring, Andrew Morton,
linux-kernel, devicetree-discuss, Libo Chen, agust, phdm,
Li Zefan
On 2013/5/22 14:06, Benjamin Herrenschmidt wrote:
> On Wed, 2013-05-22 at 12:49 +0800, Libo Chen wrote:
>> 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
>
>> On 2013/5/5 16:38, chenlibo.3@gmail.com wrote:
>>> From: Libo Chen <libo.chen@huawei.com>
>>>
>>> There is no need to free bcom_eng if kzalloc fail
>>>
>>> Signed-off-by: Libo Chen <libo.chen@huawei.com>
>>> ---
>>> drivers/dma/bestcomm/bestcomm.c | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/dma/bestcomm/bestcomm.c b/drivers/dma/bestcomm/bestcomm.c
>>> index a8c2e29..300ee2d 100644
>>> --- a/drivers/dma/bestcomm/bestcomm.c
>>> +++ b/drivers/dma/bestcomm/bestcomm.c
>>> @@ -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);
>>>
>>
>
>
>
> .
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-05-22 6:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-05 8:38 [PATCH] bestcomm: no need to free when kzalloc fail chenlibo.3
2013-05-22 4:49 ` Libo Chen
2013-05-22 4:58 ` Li Zefan
2013-05-22 6:03 ` Libo Chen
2013-05-22 6:06 ` Benjamin Herrenschmidt
2013-05-22 6:35 ` Libo Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox