w1: use put_device() if device_register() fail
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Tue, 6 Mar 2018 10:24:06 +0000 (15:54 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Mar 2018 13:58:50 +0000 (14:58 +0100)
If device_register() returned an error! Always use put_device()
to give up the reference initialized in device_register().

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/w1/w1.c

index 0c2a5a8327bd0c38b514c000ed9827656359f193..80a778b02f284d09d7744907de465d8f2b721420 100644 (file)
@@ -706,6 +706,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
                dev_err(&sl->dev,
                        "Device registration [%s] failed. err=%d\n",
                        dev_name(&sl->dev), err);
+               put_device(&sl->dev);
                return err;
        }
        w1_family_notify(BUS_NOTIFY_ADD_DEVICE, sl);