2016-04-13 07:09:10

by Fengguang Wu

[permalink] [raw]
Subject: drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c:133:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 1c74a7f812b135d3df41d7c3671b647aed6467bf
commit: b71c0892631af3dd2aea708529d282a65c683be5 drm/nouveau/iccsense: implement for ina209, ina219 and ina3221
date: 4 weeks ago


coccinelle warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c:133:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


2016-04-13 07:09:27

by Fengguang Wu

[permalink] [raw]
Subject: [PATCH] drm/nouveau/iccsense: fix ifnullfree.cocci warnings

drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c:133:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.

NULL check before some freeing functions is not needed.

Based on checkpatch warning
"kfree(NULL) is safe this check is probably not required"
and kfreeaddr.cocci by Julia Lawall.

Generated by: scripts/coccinelle/free/ifnullfree.cocci

CC: Karol Herbst <[email protected]>
Signed-off-by: Fengguang Wu <[email protected]>
---

base.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
@@ -129,8 +129,7 @@ nvkm_iccsense_dtor(struct nvkm_subdev *s
{
struct nvkm_iccsense *iccsense = nvkm_iccsense(subdev);

- if (iccsense->rails)
- kfree(iccsense->rails);
+ kfree(iccsense->rails);

return iccsense;
}

2016-04-13 07:55:48

by Martin Peres

[permalink] [raw]
Subject: Re: [PATCH] drm/nouveau/iccsense: fix ifnullfree.cocci warnings

On 13/04/16 10:07, kbuild test robot wrote:
> drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c:133:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
>
> NULL check before some freeing functions is not needed.
>
> Based on checkpatch warning
> "kfree(NULL) is safe this check is probably not required"
> and kfreeaddr.cocci by Julia Lawall.
>
> Generated by: scripts/coccinelle/free/ifnullfree.cocci
>
> CC: Karol Herbst <[email protected]>
> Signed-off-by: Fengguang Wu <[email protected]>
Signed-off-by: Martin Peres <[email protected]>

2016-04-13 10:14:19

by Karol Herbst

[permalink] [raw]
Subject: Re: [PATCH] drm/nouveau/iccsense: fix ifnullfree.cocci warnings



> Martin Peres <[email protected]> hat am 13. April 2016 um 09:55
> geschrieben:
>
>
> On 13/04/16 10:07, kbuild test robot wrote:
> > drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c:133:2-7: WARNING: NULL
> > check before freeing functions like kfree, debugfs_remove,
> > debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider
> > reorganizing relevant code to avoid passing NULL values.
> >
> > NULL check before some freeing functions is not needed.
> >
> > Based on checkpatch warning
> > "kfree(NULL) is safe this check is probably not required"
> > and kfreeaddr.cocci by Julia Lawall.
> >
> > Generated by: scripts/coccinelle/free/ifnullfree.cocci
> >
> > CC: Karol Herbst <[email protected]>
> > Signed-off-by: Fengguang Wu <[email protected]>
> Signed-off-by: Martin Peres <[email protected]>
Signed-off-by: Karol Herbst <[email protected]>