2019-04-14 05:53:10

by Julia Lawall

[permalink] [raw]
Subject: [PATCH] ZEN: fix platform_no_drv_owner.cocci warnings

From: kbuild test robot <[email protected]>

Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Fixes: 26e2aa63d568 ("ZEN: Add VHBA driver")
Signed-off-by: kbuild test robot <[email protected]>
Signed-off-by: Julia Lawall <[email protected]>

---

There was also a report about:

drivers/scsi/vhba/vhba.c:184:8-27: atomic_dec_and_test variation before
object free at line 185.

that Elena may want to comment on.


tree: https://github.com/zen-kernel/zen-kernel 5.0/misc
head: 5fbf87816fba5c14168bf5a8cf2205e072bac88f
commit: 26e2aa63d568ec48e0c062637ed5e3ca44b492e2 [7/18] ZEN: Add VHBA driver
:::::: branch date: 4 hours ago
:::::: commit date: 6 weeks ago

vhba.c | 1 -
1 file changed, 1 deletion(-)

--- a/drivers/scsi/vhba/vhba.c
+++ b/drivers/scsi/vhba/vhba.c
@@ -1033,7 +1033,6 @@ static struct platform_device vhba_platf

static struct platform_driver vhba_platform_driver = {
.driver = {
- .owner = THIS_MODULE,
.name = "vhba",
},
.probe = vhba_probe,


2019-04-15 06:33:09

by Elena Reshetova

[permalink] [raw]
Subject: RE: [PATCH] ZEN: fix platform_no_drv_owner.cocci warnings


> From: kbuild test robot <[email protected]>
>
> Remove .owner field if calls are used which set it automatically
>
> Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci
>
> Fixes: 26e2aa63d568 ("ZEN: Add VHBA driver")
> Signed-off-by: kbuild test robot <[email protected]>
> Signed-off-by: Julia Lawall <[email protected]>
>
> ---
>
> There was also a report about:
>
> drivers/scsi/vhba/vhba.c:184:8-27: atomic_dec_and_test variation before
> object free at line 185.
>
> that Elena may want to comment on.
>
>

Yes, on a quick look it seems that you should be using refcount_t type and not
atomic_t for your reference counter, as you use it as classical refcounter, i.e.
free the object upon reaching zero, etc:

static void vhba_device_put (struct vhba_device *vdev)
{
if (atomic_dec_and_test(&vdev->refcnt)) {
kfree(vdev);
}
}

Any reason why you didn't use refcount_t type to begin with?

Best Regards,
Elena.