From: sashiko-bot@kernel.org
To: "Hui Peng" <benquike@gmail.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2] scsi: sg: finish request on error in sg_read()
Date: Thu, 24 Sep 2026 05:54:07 +0000 [thread overview]
Message-ID: <20260924055408.783651F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260924054625.2282544-1-benquike@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] sg: compilation error due to undefined label free_old_hdr
--
commit 016a191c362e931770f582b73bf2ede9e57bbb56
Author: Hui Peng <benquike@gmail.com>
scsi: sg: finish request on error in sg_read()
This commit modifies sg_read() to ensure that orphaned requests are properly
finished and removed when an error occurs. It does this by introducing a new
label to call the necessary cleanup functions before returning.
> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index 3f9e08725602c..581419e1695fc 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
[ ... ]
> @@ -543,10 +545,10 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
> }
> } else
> count = (old_hdr->result == 0) ? 0 : -EIO;
> + retval = count;
> +finish_req:
> sg_finish_rem_req(srp);
> sg_remove_request(sfp, srp);
> - retval = count;
> -free_old_hdr:
[Severity: Low]
Because the free_old_hdr label is removed here, does this cause a
"label used but not defined" compilation error in sg_read()?
The error paths earlier in the function still try to jump to this deleted
label upon copy_to_user() failure and sg_read_oxfer() failure:
if (copy_to_user(buf, old_hdr, SZ_SG_HEADER)) {
retval = -EFAULT;
goto free_old_hdr;
}
...
if (sg_read_oxfer(srp, buf, count - SZ_SG_HEADER)) {
retval = -EFAULT;
goto free_old_hdr;
}
Should those goto statements be updated to jump to finish_req instead?
> kfree(old_hdr);
> return retval;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260924054625.2282544-1-benquike@gmail.com?part=1
prev parent reply other threads:[~2026-09-24 5:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 20:48 [PATCH] scsi: sg: clean up request on error paths in sg_read() Hui Peng
2026-09-21 14:47 ` John Garry
2026-09-24 5:46 ` [PATCH v2] scsi: sg: finish request on error " Hui Peng
2026-09-24 5:54 ` sashiko-bot [this message]
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=20260924055408.783651F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=benquike@gmail.com \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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