From: Bart Van Assche <bvanassche@acm.org>
To: Yingjie Wang <x-professor@outlook.com>,
"Martin K. Petersen" <mkp@kernel.org>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
Yang Xiuwei <yangxiuwei@kylinos.cn>,
James Houghton <jthoughton@google.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 2/4] scsi: core: release legacy ioctl request before user copyback
Date: Thu, 19 Nov 2026 13:36:42 -0800 [thread overview]
Message-ID: <68585ebd-db20-4277-9c45-3ee44ab2302d@acm.org> (raw)
In-Reply-To: <26e7d8d4f0648e572e6042c0ae14c1c36a83e850.1794990780.git.x-professor@outlook.com>
On 11/18/26 12:33 AM, Yingjie Wang wrote:
> + blk_mq_free_request(rq);
>
> - if (!copy_to_user(hdr->sbp, scmd->sense_buffer, len))
> - hdr->sb_len_wr = len;
> + if (sense_len) {
> + if (!copy_to_user(hdr->sbp, sense_buffer, sense_len))
> + hdr->sb_len_wr = sense_len;
> else
> ret = -EFAULT;
> }
[ ... ]
> - ret = scsi_complete_sghdr_rq(rq, hdr, bio);
> + return scsi_complete_sghdr_rq(rq, hdr, bio);
>
> out_put_request:
> blk_mq_free_request(rq);
With this patch applied scsi_complete_sghdr_rq() frees the request that
has been allocated by its caller. Nothing in the name of that function
nor in the code of sg_io() makes that clear. Please either add a comment
above scsi_complete_sghdr_rq() that explains that it frees @rq or keep
the blk_mq_free_request() call in sg_io(), e.g. by splitting
scsi_complete_sghdr_rq() into a function that saves the request state
and a function that copies that state to user space.
Thanks,
Bart.
next prev parent reply other threads:[~2026-11-19 21:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 8:33 [PATCH v4 0/4] scsi: release completed passthrough requests " Yingjie Wang
2026-11-18 8:33 ` [PATCH v4 1/4] scsi: core: release SG_IO request " Yingjie Wang
2026-11-19 21:36 ` Bart Van Assche
2026-11-18 8:33 ` [PATCH v4 2/4] scsi: core: release legacy ioctl " Yingjie Wang
2026-11-19 21:36 ` Bart Van Assche [this message]
2026-11-19 21:37 ` Bart Van Assche
2026-11-18 8:33 ` [PATCH v4 3/4] scsi: sr: release CDDA " Yingjie Wang
2026-11-18 8:33 ` [PATCH v4 4/4] scsi: bsg: release synchronous " Yingjie Wang
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=68585ebd-db20-4277-9c45-3ee44ab2302d@acm.org \
--to=bvanassche@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=jthoughton@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mkp@kernel.org \
--cc=x-professor@outlook.com \
--cc=yangxiuwei@kylinos.cn \
/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®