diff mbox

[19/38] net: atm: add missing put_device call

Message ID 1387465429-3568-20-git-send-email-levex@linux.com
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Levente Kurusa Dec. 19, 2013, 3:03 p.m. UTC
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(-)

Comments

David Miller Dec. 27, 2013, 5:40 p.m. UTC | #1
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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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]);