All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] elx: efct: Do not hold lock while calling fc_vport_terminate
@ 2021-09-07 16:52 James Smart
  2021-09-14  3:43 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: James Smart @ 2021-09-07 16:52 UTC (permalink / raw)
  To: linux-scsi; +Cc: James Smart, Dan Carpenter, Ram Vegesna

Smatch checker reported the following error:
  drivers/base/power/sysfs.c:833 dpm_sysfs_remove()
  warn: sleeping in atomic context

With a calling sequence of:
efct_lio_npiv_drop_nport() <- disables preempt
-> fc_vport_terminate()
   -> device_del()
      -> dpm_sysfs_remove()

Issue is efct_lio_npiv_drop_nport() is making the fc_vport_terminate()
call while holding a lock w/ ipl raised.

It's unnecessary to hold the lock over this call, shift where the lock
is taken.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/elx/efct/efct_lio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/elx/efct/efct_lio.c b/drivers/scsi/elx/efct/efct_lio.c
index bb3b460dc0bc..4d73e92909ab 100644
--- a/drivers/scsi/elx/efct/efct_lio.c
+++ b/drivers/scsi/elx/efct/efct_lio.c
@@ -880,11 +880,11 @@ efct_lio_npiv_drop_nport(struct se_wwn *wwn)
 	struct efct *efct = lio_vport->efct;
 	unsigned long flags = 0;
 
-	spin_lock_irqsave(&efct->tgt_efct.efct_lio_lock, flags);
-
 	if (lio_vport->fc_vport)
 		fc_vport_terminate(lio_vport->fc_vport);
 
+	spin_lock_irqsave(&efct->tgt_efct.efct_lio_lock, flags);
+
 	list_for_each_entry_safe(vport, next_vport, &efct->tgt_efct.vport_list,
 				 list_entry) {
 		if (vport->lio_vport == lio_vport) {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] elx: efct: Do not hold lock while calling fc_vport_terminate
  2021-09-07 16:52 [PATCH] elx: efct: Do not hold lock while calling fc_vport_terminate James Smart
@ 2021-09-14  3:43 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2021-09-14  3:43 UTC (permalink / raw)
  To: James Smart, linux-scsi; +Cc: Martin K . Petersen, Dan Carpenter, Ram Vegesna

On Tue, 7 Sep 2021 09:52:25 -0700, James Smart wrote:

> Smatch checker reported the following error:
>   drivers/base/power/sysfs.c:833 dpm_sysfs_remove()
>   warn: sleeping in atomic context
> 
> With a calling sequence of:
> efct_lio_npiv_drop_nport() <- disables preempt
> -> fc_vport_terminate()
>    -> device_del()
>       -> dpm_sysfs_remove()
> 
> [...]

Applied to 5.15/scsi-fixes, thanks!

[1/1] elx: efct: Do not hold lock while calling fc_vport_terminate
      https://git.kernel.org/mkp/scsi/c/450907424d9e

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-14  3:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07 16:52 [PATCH] elx: efct: Do not hold lock while calling fc_vport_terminate James Smart
2021-09-14  3:43 ` Martin K. Petersen

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.