mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] [SCSI] wd719x: Avoid calling request_firmware under spinlock
@ 2016-09-15 13:48 Vaishali Thakkar
  2016-09-15 14:08 ` John Garry
  0 siblings, 1 reply; 3+ messages in thread
From: Vaishali Thakkar @ 2016-09-15 13:48 UTC (permalink / raw)
  To: jejb; +Cc: linux-kernel, martin.petersen, linux-scsi, Vaishali Thakkar

It is preferrable to use request_firmware where sleeping is
allowed. Using it under spinlock can cause blocking. Here,
the function wd719x_chip_init calls request_firmware while
holding a spinlock. So, let's access it outside the spinlock.

Coccinelle is used to detect the issue.

Signed-off-by: Vaishali Thakkar <vaishali.thakkar@oracle.com>
---
Please note that the patch is compile-tested only. And this change
may require driver testing.
---
 drivers/scsi/wd719x.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
index e3da1a2..b8e57f3 100644
--- a/drivers/scsi/wd719x.c
+++ b/drivers/scsi/wd719x.c
@@ -518,13 +518,14 @@ static int wd719x_host_reset(struct scsi_cmnd *cmd)
 	int result;
 
 	dev_info(&wd->pdev->dev, "host reset requested\n");
-	spin_lock_irqsave(wd->sh->host_lock, flags);
+
 	/* Try to reinit the RISC */
 	if (wd719x_chip_init(wd) == 0)
 		result = SUCCESS;
 	else
 		result = FAILED;
 
+	spin_lock_irqsave(wd->sh->host_lock, flags);
 	/* flush all SCBs */
 	list_for_each_entry_safe(scb, tmp, &wd->active_scbs, list) {
 		struct scsi_cmnd *tmp_cmd = scb->cmd;
-- 
2.1.4

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

end of thread, other threads:[~2016-09-15 14:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-15 13:48 [PATCH] [SCSI] wd719x: Avoid calling request_firmware under spinlock Vaishali Thakkar
2016-09-15 14:08 ` John Garry
2016-09-15 14:14   ` John Garry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®