diff mbox series

scsi: core: Fix a procfs host directory removal regression

Message ID 20230307214428.3703498-1-bvanassche@acm.org
State New
Headers show
Series scsi: core: Fix a procfs host directory removal regression | expand

Commit Message

Bart Van Assche March 7, 2023, 9:44 p.m. UTC
scsi_proc_hostdir_rm() decreases a reference counter and hence must
only be called once per host that is removed. This change does not
require a scsi_add_host_with_dma() change since scsi_add_host_with_dma()
will return 0 (success) if scsi_proc_host_add() is called.

Cc: John Garry <john.g.garry@oracle.com>
Reported-by: John Garry <john.g.garry@oracle.com>
Reported-by: syzbot+645a4616b87a2f10e398@syzkaller.appspotmail.com
Fixes: fc663711b944 ("scsi: core: Remove the /proc/scsi/${proc_name} directory earlier")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/hosts.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

Shin'ichiro Kawasaki March 9, 2023, 8:27 a.m. UTC | #1
On Mar 07, 2023 / 13:44, Bart Van Assche wrote:
> scsi_proc_hostdir_rm() decreases a reference counter and hence must
> only be called once per host that is removed. This change does not
> require a scsi_add_host_with_dma() change since scsi_add_host_with_dma()
> will return 0 (success) if scsi_proc_host_add() is called.
> 
> Cc: John Garry <john.g.garry@oracle.com>
> Reported-by: John Garry <john.g.garry@oracle.com>
> Reported-by: syzbot+645a4616b87a2f10e398@syzkaller.appspotmail.com
> Fixes: fc663711b944 ("scsi: core: Remove the /proc/scsi/${proc_name} directory earlier")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

When I ran blktests test case block/001 on the linux kernel v6.3-rc1, I observed
WARNs in remove_proc_entry(). I found this patch avoids the WARNs. Thanks.

Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
diff mbox series

Patch

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index f7f62e56afca..9b6fbbe15d92 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -341,9 +341,6 @@  static void scsi_host_dev_release(struct device *dev)
 	struct Scsi_Host *shost = dev_to_shost(dev);
 	struct device *parent = dev->parent;
 
-	/* In case scsi_remove_host() has not been called. */
-	scsi_proc_hostdir_rm(shost->hostt);
-
 	/* Wait for functions invoked through call_rcu(&scmd->rcu, ...) */
 	rcu_barrier();