All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] scsi: ch: add scsi_device_put in ch_readconfig
@ 2022-07-19  7:54 Yang Hao
  0 siblings, 0 replies; only message in thread
From: Yang Hao @ 2022-07-19  7:54 UTC (permalink / raw)
  To: jejb, martin.petersen; +Cc: linux-scsi, linux-kernel, Yang Hao

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-19  7:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19  7:54 [RFC] scsi: ch: add scsi_device_put in ch_readconfig Yang Hao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.