From: Jeff Moyer <jmoyer@redhat.com>
To: Joe Lawrence <joe.lawrence@stratus.com>
Cc: <linux-kernel@vger.kernel.org>, Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH 1/2] block,scsi: verify return pointer from blk_get_request
Date: Tue, 03 Jun 2014 15:36:09 -0400 [thread overview]
Message-ID: <x49vbshvl92.fsf@segfault.boston.devel.redhat.com> (raw)
In-Reply-To: <1401396529-17275-2-git-send-email-joe.lawrence@stratus.com> (Joe Lawrence's message of "Thu, 29 May 2014 16:48:48 -0400")
Joe Lawrence <joe.lawrence@stratus.com> writes:
> The blk-core dead queue checks introduce an error scenario to
> blk_get_request that returns NULL if the request queue has been
> shutdown. This affects the behavior for __GFP_WAIT callers, who should
> verify the return value before dereferencing.
>
> Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com>
> Acked-by: Jiri Kosina <jkosina@suse.cz> [for pktdvd]
Acked-by: Jeff Moyer <jmoyer@redhat.com>
> ---
> block/scsi_ioctl.c | 9 ++++++++-
> drivers/block/paride/pd.c | 2 ++
> drivers/block/pktcdvd.c | 2 ++
> drivers/scsi/scsi_error.c | 2 ++
> 4 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
> index 2648797..e6485c9 100644
> --- a/block/scsi_ioctl.c
> +++ b/block/scsi_ioctl.c
> @@ -442,6 +442,10 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
> }
>
> rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT);
> + if (!rq) {
> + err = -ENODEV;
> + goto error_free_buffer;
> + }
>
> cmdlen = COMMAND_SIZE(opcode);
>
> @@ -514,8 +518,9 @@ out:
> }
>
> error:
> - kfree(buffer);
> blk_put_request(rq);
> +error_free_buffer:
> + kfree(buffer);
> return err;
> }
> EXPORT_SYMBOL_GPL(sg_scsi_ioctl);
> @@ -528,6 +533,8 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk,
> int err;
>
> rq = blk_get_request(q, WRITE, __GFP_WAIT);
> + if (!rq)
> + return -ENODEV;
> rq->cmd_type = REQ_TYPE_BLOCK_PC;
> rq->timeout = BLK_DEFAULT_SG_TIMEOUT;
> rq->cmd[0] = cmd;
> diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
> index 19ad8f0..856178a 100644
> --- a/drivers/block/paride/pd.c
> +++ b/drivers/block/paride/pd.c
> @@ -722,6 +722,8 @@ static int pd_special_command(struct pd_unit *disk,
> int err = 0;
>
> rq = blk_get_request(disk->gd->queue, READ, __GFP_WAIT);
> + if (!rq)
> + return -ENODEV;
>
> rq->cmd_type = REQ_TYPE_SPECIAL;
> rq->special = func;
> diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
> index a2af73d..ff39837 100644
> --- a/drivers/block/pktcdvd.c
> +++ b/drivers/block/pktcdvd.c
> @@ -704,6 +704,8 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *
>
> rq = blk_get_request(q, (cgc->data_direction == CGC_DATA_WRITE) ?
> WRITE : READ, __GFP_WAIT);
> + if (!rq)
> + return -ENODEV;
>
> if (cgc->buflen) {
> ret = blk_rq_map_kern(q, rq, cgc->buffer, cgc->buflen,
> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> index f17aa7a..d50531f 100644
> --- a/drivers/scsi/scsi_error.c
> +++ b/drivers/scsi/scsi_error.c
> @@ -1950,6 +1950,8 @@ static void scsi_eh_lock_door(struct scsi_device *sdev)
> * request becomes available
> */
> req = blk_get_request(sdev->request_queue, READ, GFP_KERNEL);
> + if (!req)
> + return;
>
> req->cmd[0] = ALLOW_MEDIUM_REMOVAL;
> req->cmd[1] = 0;
next prev parent reply other threads:[~2014-06-03 19:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-29 20:48 [PATCH 0/2] block,scsi: fixup blk_get_request dead queue scenarios Joe Lawrence
2014-05-29 20:48 ` [PATCH 1/2] block,scsi: verify return pointer from blk_get_request Joe Lawrence
2014-06-03 19:36 ` Jeff Moyer [this message]
2014-05-29 20:48 ` [PATCH 2/2] block,scsi: convert and handle ERR_PTR " Joe Lawrence
2014-06-03 19:45 ` Jeff Moyer
2014-06-03 20:21 ` Joe Lawrence
2014-06-03 20:07 ` Jeff Moyer
2014-06-03 21:26 ` Joe Lawrence
2014-06-04 18:07 ` Jeff Moyer
2014-06-17 10:33 ` Christoph Hellwig
2014-06-17 14:25 ` Joe Lawrence
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=x49vbshvl92.fsf@segfault.boston.devel.redhat.com \
--to=jmoyer@redhat.com \
--cc=axboe@kernel.dk \
--cc=joe.lawrence@stratus.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®