2018-09-21 13:31:32

by zhong jiang

[permalink] [raw]
Subject: [PATCH] PM / devfreq: remove redundant null pointer check before kfree

kfree has taken the null pointer into account. hence it is safe
to remove the redundant null pointer check before kfree.

Signed-off-by: zhong jiang <[email protected]>
---
drivers/devfreq/devfreq.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 4c49bb1..c37021d 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -675,8 +675,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
device_unregister(&devfreq->dev);
devfreq = NULL;
err_dev:
- if (devfreq)
- kfree(devfreq);
+ kfree(devfreq);
err_out:
return ERR_PTR(err);
}
--
1.7.12.4



2018-09-27 02:36:51

by MyungJoo Ham

[permalink] [raw]
Subject: RE: [PATCH] PM / devfreq: remove redundant null pointer check before kfree

 
> kfree has taken the null pointer into account. hence it is safe
> to remove the redundant null pointer check before kfree.
>
> Signed-off-by: zhong jiang <[email protected]>

Acked-by: MyungJoo Ham <[email protected]>

> ---
> drivers/devfreq/devfreq.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 4c49bb1..c37021d 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -675,8 +675,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
> device_unregister(&devfreq->dev);
> devfreq = NULL;
> err_dev:
> - if (devfreq)
> - kfree(devfreq);
> + kfree(devfreq);
> err_out:
> return ERR_PTR(err);
> }
> --
> 1.7.12.4

 
--
MyungJoo Ham (함명주), Ph.D.
Autonomous Machine Lab., AI Center, Samsung Research.
Cell: +82-10-6714-2858