[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <fa970be78de11dee1a217c9a75ab0850f1780e0c.1520591977.git.arvind.yadav.cs@gmail.com>
Date: Fri, 9 Mar 2018 16:11:17 +0530
From: Arvind Yadav <arvind.yadav.cs@...il.com>
To: yisen.zhuang@...wei.com, salil.mehta@...wei.com,
linyunsheng@...wei.com
Cc: linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: [PATCH] net: hns: use put_device() if device_register fail
if device_register() returned an error! Always use put_device()
to give up the reference initialized.
Signed-off-by: Arvind Yadav <arvind.yadav.cs@...il.com>
---
drivers/net/ethernet/hisilicon/hns/hnae.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
index a051e58..0cf5ceb 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.c
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
@@ -422,8 +422,10 @@ int hnae_ae_register(struct hnae_ae_dev *hdev, struct module *owner)
hdev->cls_dev.release = hnae_release;
(void)dev_set_name(&hdev->cls_dev, "hnae%d", hdev->id);
ret = device_register(&hdev->cls_dev);
- if (ret)
+ if (ret) {
+ put_device(&hdev->cls_dev);
return ret;
+ }
__module_get(THIS_MODULE);
--
1.9.1
Powered by blists - more mailing lists