* [PATCH 19/38] net: atm: add missing put_device call
[not found] <1387465429-3568-2-git-send-email-levex@linux.com>
@ 2013-12-19 15:03 ` Levente Kurusa
2013-12-27 17:40 ` David Miller
2013-12-19 15:03 ` [PATCH 20/38] net: iucv: " Levente Kurusa
1 sibling, 1 reply; 4+ messages in thread
From: Levente Kurusa @ 2013-12-19 15:03 UTC (permalink / raw)
To: LKML; +Cc: Levente Kurusa, David S. Miller, netdev
This is required so that we give up the last reference to the device.
Signed-off-by: Levente Kurusa <levex@linux.com>
---
net/atm/atm_sysfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/atm/atm_sysfs.c b/net/atm/atm_sysfs.c
index 350bf62..0e070c2 100644
--- a/net/atm/atm_sysfs.c
+++ b/net/atm/atm_sysfs.c
@@ -154,8 +154,10 @@ int atm_register_sysfs(struct atm_dev *adev, struct device *parent)
dev_set_name(cdev, "%s%d", adev->type, adev->number);
err = device_register(cdev);
- if (err < 0)
+ if (err < 0) {
+ put_device(cdev);
return err;
+ }
for (i = 0; atm_attrs[i]; i++) {
err = device_create_file(cdev, atm_attrs[i]);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 20/38] net: iucv: add missing put_device call
[not found] <1387465429-3568-2-git-send-email-levex@linux.com>
2013-12-19 15:03 ` [PATCH 19/38] net: atm: add missing put_device call Levente Kurusa
@ 2013-12-19 15:03 ` Levente Kurusa
2013-12-27 17:41 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Levente Kurusa @ 2013-12-19 15:03 UTC (permalink / raw)
To: LKML
Cc: Levente Kurusa, Ursula Braun, linux390, David S. Miller,
linux-s390, netdev
This is required so that we give up the last reference to the device.
Signed-off-by: Levente Kurusa <levex@linux.com>
---
net/iucv/af_iucv.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 168aff5..0096206 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -2377,8 +2377,10 @@ static int afiucv_iucv_init(void)
af_iucv_dev->release = (void (*)(struct device *))kfree;
af_iucv_dev->driver = &af_iucv_driver;
err = device_register(af_iucv_dev);
- if (err)
+ if (err) {
+ put_device(af_iucv_dev);
goto out_driver;
+ }
return 0;
out_driver:
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 19/38] net: atm: add missing put_device call
2013-12-19 15:03 ` [PATCH 19/38] net: atm: add missing put_device call Levente Kurusa
@ 2013-12-27 17:40 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2013-12-27 17:40 UTC (permalink / raw)
To: levex; +Cc: linux-kernel, netdev
From: Levente Kurusa <levex@linux.com>
Date: Thu, 19 Dec 2013 16:03:30 +0100
> This is required so that we give up the last reference to the device.
>
> Signed-off-by: Levente Kurusa <levex@linux.com>
...
> @@ -154,8 +154,10 @@ int atm_register_sysfs(struct atm_dev *adev, struct device *parent)
>
> dev_set_name(cdev, "%s%d", adev->type, adev->number);
> err = device_register(cdev);
> - if (err < 0)
> + if (err < 0) {
> + put_device(cdev);
> return err;
> + }
This doesn't make any sense.
Nothing has a reference to 'cdev'. Yes, 'adev' has a reference,
acquired by the caller of this function, but that's not what we're
working with here.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 20/38] net: iucv: add missing put_device call
2013-12-19 15:03 ` [PATCH 20/38] net: iucv: " Levente Kurusa
@ 2013-12-27 17:41 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2013-12-27 17:41 UTC (permalink / raw)
To: levex; +Cc: linux-kernel, ursula.braun, linux390, linux-s390, netdev
From: Levente Kurusa <levex@linux.com>
Date: Thu, 19 Dec 2013 16:03:31 +0100
> This is required so that we give up the last reference to the device.
>
> Signed-off-by: Levente Kurusa <levex@linux.com>
...
> @@ -2377,8 +2377,10 @@ static int afiucv_iucv_init(void)
> af_iucv_dev->release = (void (*)(struct device *))kfree;
> af_iucv_dev->driver = &af_iucv_driver;
> err = device_register(af_iucv_dev);
> - if (err)
> + if (err) {
> + put_device(af_iucv_dev);
> goto out_driver;
> + }
This has the same problem as the ATM patch, there is no reference held on
af_iucv_dev, I mean look at where it comes from:
af_iucv_dev = kzalloc(sizeof(struct device), GFP_KERNEL);
...
dev_set_name(af_iucv_dev, "af_iucv");
af_iucv_dev->bus = pr_iucv->bus;
af_iucv_dev->parent = pr_iucv->root;
af_iucv_dev->release = (void (*)(struct device *))kfree;
af_iucv_dev->driver = &af_iucv_driver;
No reference count is incremented or set to one for af_iucv_dev.
Please study these code paths more carefully, thank you.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-12-27 17:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1387465429-3568-2-git-send-email-levex@linux.com>
2013-12-19 15:03 ` [PATCH 19/38] net: atm: add missing put_device call Levente Kurusa
2013-12-27 17:40 ` David Miller
2013-12-19 15:03 ` [PATCH 20/38] net: iucv: " Levente Kurusa
2013-12-27 17:41 ` David Miller
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).