diff mbox series

[RFC] scsi: ch: add scsi_device_put in ch_readconfig

Message ID 20220719075442.6215-1-yanghao_ht@163.com (mailing list archive)
State Deferred
Headers show
Series [RFC] scsi: ch: add scsi_device_put in ch_readconfig | expand

Commit Message

Yang Hao July 19, 2022, 7:54 a.m. UTC
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@163.com>
---
 drivers/scsi/ch.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

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;
 			}
 		}
 	}