target: tcm_loop: use put_device() if device_register fail
diff mbox

Message ID 4903df0f8cc170db01c65ead87d3b7af9fa269c8.1520415984.git.arvind.yadav.cs@gmail.com
State New, archived
Headers show

Commit Message

Arvind Yadav March 7, 2018, 9:48 a.m. UTC
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>
---
 drivers/target/loopback/tcm_loop.c | 1 +
 1 file changed, 1 insertion(+)

Patch
diff mbox

diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index 9cd4ffe..5dffc55 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -412,6 +412,7 @@  static int tcm_loop_setup_hba_bus(struct tcm_loop_hba *tl_hba, int tcm_loop_host
 	ret = device_register(&tl_hba->dev);
 	if (ret) {
 		pr_err("device_register() failed for tl_hba->dev: %d\n", ret);
+		put_device(&tl_hba->dev);
 		return -ENODEV;
 	}