* [PATCH 0/2] misc: use put_device() instead of kfree()
@ 2018-03-12 11:36 Arvind Yadav
2018-03-12 11:36 ` [PATCH 1/2] misc: mic: Release reference count and memory for VOP device Arvind Yadav
2018-03-12 11:36 ` [PATCH 2/2] misc: ocxl: use put_device() instead of device_unregister() Arvind Yadav
0 siblings, 2 replies; 5+ messages in thread
From: Arvind Yadav @ 2018-03-12 11:36 UTC (permalink / raw)
To: sudeep.dutt, ashutosh.dixit, arnd, gregkh, fbarrat, andrew.donnellan
Cc: linux-kernel, linuxppc-dev
Never directly free @dev after calling device_register(), even
if it returned an error! Always use put_device() to give up the
reference initialized.
Arvind Yadav (2):
[PATCH 1/2] misc: mic: Release reference count and memory for VOP device
[PATCH 2/2] misc: ocxl: use put_device() instead of device_unregister()
drivers/misc/mic/bus/vop_bus.c | 6 ++++--
drivers/misc/ocxl/pci.c | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] misc: mic: Release reference count and memory for VOP device
2018-03-12 11:36 [PATCH 0/2] misc: use put_device() instead of kfree() Arvind Yadav
@ 2018-03-12 11:36 ` Arvind Yadav
2018-03-12 11:36 ` [PATCH 2/2] misc: ocxl: use put_device() instead of device_unregister() Arvind Yadav
1 sibling, 0 replies; 5+ messages in thread
From: Arvind Yadav @ 2018-03-12 11:36 UTC (permalink / raw)
To: sudeep.dutt, ashutosh.dixit, arnd, gregkh, fbarrat, andrew.donnellan
Cc: linux-kernel, linuxppc-dev
Never directly free @dev after calling device_register(),
even if it returned an error! Always use put_device() to
give up the reference initialized.
Release allocated memory for vop device in vop_release_dev().
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
drivers/misc/mic/bus/vop_bus.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/mic/bus/vop_bus.c b/drivers/misc/mic/bus/vop_bus.c
index fd7f2a6..e5bb9c7 100644
--- a/drivers/misc/mic/bus/vop_bus.c
+++ b/drivers/misc/mic/bus/vop_bus.c
@@ -135,7 +135,9 @@ void vop_unregister_driver(struct vop_driver *driver)
static void vop_release_dev(struct device *d)
{
- put_device(d);
+ struct vop_device *dev = dev_to_vop(d);
+
+ kfree(dev);
}
struct vop_device *
@@ -174,7 +176,7 @@ struct vop_device *
goto free_vdev;
return vdev;
free_vdev:
- kfree(vdev);
+ put_device(&vdev->dev);
return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(vop_register_device);
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] misc: ocxl: use put_device() instead of device_unregister()
2018-03-12 11:36 [PATCH 0/2] misc: use put_device() instead of kfree() Arvind Yadav
2018-03-12 11:36 ` [PATCH 1/2] misc: mic: Release reference count and memory for VOP device Arvind Yadav
@ 2018-03-12 11:36 ` Arvind Yadav
2018-03-13 0:26 ` Andrew Donnellan
2018-03-13 9:38 ` Frederic Barrat
1 sibling, 2 replies; 5+ messages in thread
From: Arvind Yadav @ 2018-03-12 11:36 UTC (permalink / raw)
To: sudeep.dutt, ashutosh.dixit, arnd, gregkh, fbarrat, andrew.donnellan
Cc: linux-kernel, linuxppc-dev
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 778 bytes --]
if device_register() returned an error! Always use put_device()
to give up the reference initialized.
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
---
drivers/misc/ocxl/pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/ocxl/pci.c b/drivers/misc/ocxl/pci.c
index 0051d9e..21f4254 100644
--- a/drivers/misc/ocxl/pci.c
+++ b/drivers/misc/ocxl/pci.c
@@ -519,7 +519,7 @@ static struct ocxl_fn *init_function(struct pci_dev *dev)
rc = device_register(&fn->dev);
if (rc) {
deconfigure_function(fn);
- device_unregister(&fn->dev);
+ put_device(&fn->dev);
return ERR_PTR(rc);
}
return fn;
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] misc: ocxl: use put_device() instead of device_unregister()
2018-03-12 11:36 ` [PATCH 2/2] misc: ocxl: use put_device() instead of device_unregister() Arvind Yadav
@ 2018-03-13 0:26 ` Andrew Donnellan
2018-03-13 9:38 ` Frederic Barrat
1 sibling, 0 replies; 5+ messages in thread
From: Andrew Donnellan @ 2018-03-13 0:26 UTC (permalink / raw)
To: Arvind Yadav, sudeep.dutt, ashutosh.dixit, arnd, gregkh, fbarrat
Cc: linux-kernel, linuxppc-dev
On 12/03/18 22:36, Arvind Yadav wrote:
> if device_register() returned an error! Always use put_device()
> to give up the reference initialized.
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
This looks right, thanks for picking it up.
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
--
Andrew Donnellan OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com IBM Australia Limited
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] misc: ocxl: use put_device() instead of device_unregister()
2018-03-12 11:36 ` [PATCH 2/2] misc: ocxl: use put_device() instead of device_unregister() Arvind Yadav
2018-03-13 0:26 ` Andrew Donnellan
@ 2018-03-13 9:38 ` Frederic Barrat
1 sibling, 0 replies; 5+ messages in thread
From: Frederic Barrat @ 2018-03-13 9:38 UTC (permalink / raw)
To: Arvind Yadav, sudeep.dutt, ashutosh.dixit, arnd, gregkh,
andrew.donnellan
Cc: linux-kernel, linuxppc-dev
Le 12/03/2018 à 12:36, Arvind Yadav a écrit :
> if device_register() returned an error! Always use put_device()
> to give up the reference initialized.
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
OK, device_unregister() calls put_device() but also other actions that
we can skip in this case.
Acked-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
> drivers/misc/ocxl/pci.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/ocxl/pci.c b/drivers/misc/ocxl/pci.c
> index 0051d9e..21f4254 100644
> --- a/drivers/misc/ocxl/pci.c
> +++ b/drivers/misc/ocxl/pci.c
> @@ -519,7 +519,7 @@ static struct ocxl_fn *init_function(struct pci_dev *dev)
> rc = device_register(&fn->dev);
> if (rc) {
> deconfigure_function(fn);
> - device_unregister(&fn->dev);
> + put_device(&fn->dev);
> return ERR_PTR(rc);
> }
> return fn;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-03-13 9:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-12 11:36 [PATCH 0/2] misc: use put_device() instead of kfree() Arvind Yadav
2018-03-12 11:36 ` [PATCH 1/2] misc: mic: Release reference count and memory for VOP device Arvind Yadav
2018-03-12 11:36 ` [PATCH 2/2] misc: ocxl: use put_device() instead of device_unregister() Arvind Yadav
2018-03-13 0:26 ` Andrew Donnellan
2018-03-13 9:38 ` Frederic Barrat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).