[RFC] scsi: ch: add scsi_device_put in ch_readconfig

From: Yang Hao
Date: Tue Jul 19 2022 - 03:56:09 EST


ch_probe
ch_readconfig
scsi_device_lookup
scsi_device_get
...

when the dev is found, the related refcnt of dev will increase,
and there is no 'scsi_device_put' to decrease it, which will lead
to refcnt leak.

Signed-off-by: Yang Hao <yanghao_ht@xxxxxxx>
---
drivers/scsi/ch.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 27012908b..70ba5d63e 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -407,6 +407,8 @@ ch_readconfig(scsi_changer *ch)
ch->dt[elem]->vendor,
ch->dt[elem]->model,
ch->dt[elem]->rev);
+ scsi_device_put(ch->dt[elem]);
+ ch->dt[elem] = NULL;
}
}
}
--
2.25.1