* [PATCH 4/7] IB/srp: Avoid a cable pull can trigger a kernel crash
[not found] <20171006214243.11296-1-bart.vanassche@wdc.com>
@ 2017-10-06 21:42 ` Bart Van Assche
2017-10-08 13:22 ` Leon Romanovsky
2017-10-11 12:36 ` Sagi Grimberg
0 siblings, 2 replies; 4+ messages in thread
From: Bart Van Assche @ 2017-10-06 21:42 UTC (permalink / raw)
To: Doug Ledford; +Cc: linux-rdma, Bart Van Assche, stable
This patch fixes the following kernel crash:
general protection fault: 0000 [#1] PREEMPT SMP
Workqueue: ib_mad2 timeout_sends [ib_core]
Call Trace:
ib_sa_path_rec_callback+0x1c4/0x1d0 [ib_core]
send_handler+0xb2/0xd0 [ib_core]
timeout_sends+0x14d/0x220 [ib_core]
process_one_work+0x200/0x630
worker_thread+0x4e/0x3b0
kthread+0x113/0x150
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: <stable@vger.kernel.org>
---
drivers/infiniband/ulp/srp/ib_srp.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 778a08250f16..8ceb4bb011f1 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -665,12 +665,19 @@ static void srp_path_rec_completion(int status,
static int srp_lookup_path(struct srp_rdma_ch *ch)
{
struct srp_target_port *target = ch->target;
- int ret;
+ int ret = -ENODEV;
ch->path.numb_path = 1;
init_completion(&ch->done);
+ /*
+ * Avoid that the SCSI host can be removed by srp_remove_target()
+ * before srp_path_rec_completion() is called.
+ */
+ if (!scsi_host_get(target->scsi_host))
+ goto out;
+
ch->path_query_id = ib_sa_path_rec_get(&srp_sa_client,
target->srp_host->srp_dev->dev,
target->srp_host->port,
@@ -684,18 +691,24 @@ static int srp_lookup_path(struct srp_rdma_ch *ch)
GFP_KERNEL,
srp_path_rec_completion,
ch, &ch->path_query);
- if (ch->path_query_id < 0)
- return ch->path_query_id;
+ ret = ch->path_query_id;
+ if (ret < 0)
+ goto put;
ret = wait_for_completion_interruptible(&ch->done);
if (ret < 0)
- return ret;
+ goto put;
- if (ch->status < 0)
+ ret = ch->status;
+ if (ret < 0)
shost_printk(KERN_WARNING, target->scsi_host,
PFX "Path record query failed\n");
- return ch->status;
+put:
+ scsi_host_put(target->scsi_host);
+
+out:
+ return ret;
}
static int srp_send_req(struct srp_rdma_ch *ch, bool multich)
--
2.14.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 4/7] IB/srp: Avoid a cable pull can trigger a kernel crash
2017-10-06 21:42 ` [PATCH 4/7] IB/srp: Avoid a cable pull can trigger a kernel crash Bart Van Assche
@ 2017-10-08 13:22 ` Leon Romanovsky
2017-10-09 17:02 ` Bart Van Assche
2017-10-11 12:36 ` Sagi Grimberg
1 sibling, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2017-10-08 13:22 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Doug Ledford, linux-rdma, stable
[-- Attachment #1: Type: text/plain, Size: 570 bytes --]
On Fri, Oct 06, 2017 at 02:42:40PM -0700, Bart Van Assche wrote:
> This patch fixes the following kernel crash:
>
> general protection fault: 0000 [#1] PREEMPT SMP
> Workqueue: ib_mad2 timeout_sends [ib_core]
> Call Trace:
> ib_sa_path_rec_callback+0x1c4/0x1d0 [ib_core]
> send_handler+0xb2/0xd0 [ib_core]
> timeout_sends+0x14d/0x220 [ib_core]
> process_one_work+0x200/0x630
> worker_thread+0x4e/0x3b0
> kthread+0x113/0x150
>
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: <stable@vger.kernel.org>
You need Fixes tag for the stable tree.
Thanks
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 4/7] IB/srp: Avoid a cable pull can trigger a kernel crash
2017-10-08 13:22 ` Leon Romanovsky
@ 2017-10-09 17:02 ` Bart Van Assche
0 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2017-10-09 17:02 UTC (permalink / raw)
To: leon@kernel.org
Cc: linux-rdma@vger.kernel.org, stable@vger.kernel.org,
dledford@redhat.com
On Sun, 2017-10-08 at 16:22 +0300, Leon Romanovsky wrote:
> On Fri, Oct 06, 2017 at 02:42:40PM -0700, Bart Van Assche wrote:
> > This patch fixes the following kernel crash:
> >
> > general protection fault: 0000 [#1] PREEMPT SMP
> > Workqueue: ib_mad2 timeout_sends [ib_core]
> > Call Trace:
> > ib_sa_path_rec_callback+0x1c4/0x1d0 [ib_core]
> > send_handler+0xb2/0xd0 [ib_core]
> > timeout_sends+0x14d/0x220 [ib_core]
> > process_one_work+0x200/0x630
> > worker_thread+0x4e/0x3b0
> > kthread+0x113/0x150
> >
> > Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> > Cc: <stable@vger.kernel.org>
>
> You need Fixes tag for the stable tree.
Hello Leon,
OK, I will add that tag when I repost this patch series.
Bart.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 4/7] IB/srp: Avoid a cable pull can trigger a kernel crash
2017-10-06 21:42 ` [PATCH 4/7] IB/srp: Avoid a cable pull can trigger a kernel crash Bart Van Assche
2017-10-08 13:22 ` Leon Romanovsky
@ 2017-10-11 12:36 ` Sagi Grimberg
1 sibling, 0 replies; 4+ messages in thread
From: Sagi Grimberg @ 2017-10-11 12:36 UTC (permalink / raw)
To: Bart Van Assche, Doug Ledford; +Cc: linux-rdma, stable
Looks good,
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-10-11 12:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20171006214243.11296-1-bart.vanassche@wdc.com>
2017-10-06 21:42 ` [PATCH 4/7] IB/srp: Avoid a cable pull can trigger a kernel crash Bart Van Assche
2017-10-08 13:22 ` Leon Romanovsky
2017-10-09 17:02 ` Bart Van Assche
2017-10-11 12:36 ` Sagi Grimberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox