From: sashiko-bot@kernel.org
To: "John Garry" <john.g.garry@oracle.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 14/17] scsi: sd: add multipath disk attr groups
Date: Fri, 03 Jul 2026 12:25:14 +0000 [thread overview]
Message-ID: <20260703122515.6B9AC1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260703103402.3725011-15-john.g.garry@oracle.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Low] The patch references several undeclared identifiers and undefined functions, which will cause fatal compilation and linker errors.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but error paths in `sd_mpath_probe()` incorrectly use `kfree()` instead of `put_device()` after `device_initialize()`, leaking kobject resources. Furthermore, it cannot trivially use `put_device()` without causing a use-after-free and IDA corruption.
--
commit c032527f31f85b7a1e95cfcc2527fe7e368f3474
Author: John Garry <john.g.garry@oracle.com>
scsi: sd: add multipath disk attr groups
Set multipath disk attr groups, which includes delayed disk removal and
everything from mpath_attr_group.
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 3df70b24b688e..a9a29e50f5eec 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
[ ... ]
> @@ -4106,6 +4106,41 @@ static void sd_mpath_add_disk(struct scsi_disk *sdkp)
> mpath_device_set_live(mpath_device);
> }
>
> +static ssize_t sd_mpath_device_delayed_removal_store(struct device *dev,
> + struct device_attribute *attr, const char *buf, size_t count)
> +{
> + struct mpath_head *mpath_head = mpath_bd_device_to_head(dev);
> +
> + return mpath_delayed_removal_secs_store(mpath_head, buf, count);
> +}
> +
> +static ssize_t sd_mpath_device_delayed_removal_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct mpath_head *mpath_head = mpath_bd_device_to_head(dev);
> +
> + return mpath_delayed_removal_secs_show(mpath_head, buf);
> +}
[Severity: Low]
Are the functions mpath_bd_device_to_head(), mpath_delayed_removal_secs_store(),
and mpath_delayed_removal_secs_show() declared anywhere? It looks like they
might be missing, which would cause a build error.
> +
> +static DEVICE_ATTR(delayed_removal_secs, S_IRUGO | S_IWUSR,
> + sd_mpath_device_delayed_removal_show,
> + sd_mpath_device_delayed_removal_store);
> +
> +static struct attribute *sd_mpath_disk_attrs[] = {
> + &dev_attr_delayed_removal_secs.attr,
> + NULL
> +};
> +
> +static const struct attribute_group sd_mpath_disk_attr_group = {
> + .attrs = sd_mpath_disk_attrs,
> +};
> +
> +static const struct attribute_group *sd_mpath_disk_attr_groups[] = {
> + &sd_mpath_disk_attr_group,
> + &mpath_attr_group,
[Severity: Low]
Is the external variable mpath_attr_group declared and defined? Building with
this patch applied results in an undeclared identifier error.
> + NULL
> +};
> +
> static int sd_mpath_probe(struct scsi_disk *sdkp)
> {
> struct scsi_device *sdp = sdkp->device;
> @@ -4161,6 +4196,7 @@ static int sd_mpath_probe(struct scsi_disk *sdkp)
>
> mpath_head->parent = &sd_mpath_disk->dev;
> mpath_head->drv_module = THIS_MODULE;
> + mpath_head->disk_groups = sd_mpath_disk_attr_groups;
> error = mpath_alloc_head_disk(mpath_head, &lim,
> dev_to_node(dma_dev));
> if (error)
[Severity: High]
This isn't a bug introduced by this patch, but since we are modifying
sd_mpath_probe(), is it safe to use kfree() on error paths after
device_initialize() has been called on sd_mpath_disk->dev?
If mpath_alloc_head_disk() fails, the code jumps to out_free_disk:
drivers/scsi/sd.c:sd_mpath_probe() {
...
device_initialize(&sd_mpath_disk->dev);
...
error = mpath_alloc_head_disk(mpath_head, &lim, dev_to_node(dma_dev));
if (error)
goto out_free_disk;
...
out_free_disk:
kfree(sd_mpath_disk);
...
}
Should this use put_device() instead to ensure the kobject internals are
properly cleaned up?
However, calling put_device() would invoke sd_mpath_disk_release(), which
unconditionally calls ida_free() and scsi_mpath_put_head(). Would
sd_mpath_disk_release() need to be updated to handle partial initialization if
put_device() were used here?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260703103402.3725011-1-john.g.garry@oracle.com?part=14
next prev parent reply other threads:[~2026-07-03 12:25 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 10:33 [PATCH v3 00/17] Native SCSI multipath support John Garry
2026-07-03 10:33 ` [PATCH v3 01/17] scsi-multipath: introduce basic SCSI device support John Garry
2026-07-03 10:53 ` sashiko-bot
2026-07-06 14:39 ` John Garry
2026-07-03 10:33 ` [PATCH v3 02/17] scsi-multipath: introduce scsi_device head structure John Garry
2026-07-03 10:49 ` sashiko-bot
2026-07-06 14:45 ` John Garry
2026-07-03 10:33 ` [PATCH v3 03/17] scsi-multipath: provide sysfs link from to scsi_device John Garry
2026-07-03 11:04 ` sashiko-bot
2026-07-03 10:33 ` [PATCH v3 04/17] scsi-multipath: support iopolicy John Garry
2026-07-03 11:10 ` sashiko-bot
2026-07-06 14:49 ` John Garry
2026-07-03 10:33 ` [PATCH v3 05/17] scsi-multipath: clone each bio John Garry
2026-07-03 11:26 ` sashiko-bot
2026-07-06 14:53 ` John Garry
2026-07-03 10:33 ` [PATCH v3 06/17] scsi-multipath: clear path when device is blocked John Garry
2026-07-03 11:32 ` sashiko-bot
2026-07-06 15:04 ` John Garry
2026-07-03 10:33 ` [PATCH v3 07/17] scsi-multipath: failover handling John Garry
2026-07-03 11:40 ` sashiko-bot
2026-07-06 15:32 ` John Garry
2026-07-03 10:33 ` [PATCH v3 08/17] scsi-multipath: provide callbacks for path state John Garry
2026-07-03 11:49 ` sashiko-bot
2026-07-06 15:38 ` John Garry
2026-07-03 10:33 ` [PATCH v3 09/17] scsi-multipath: add scsi_mpath_{start,end}_request() John Garry
2026-07-03 11:53 ` sashiko-bot
2026-07-06 15:44 ` John Garry
2026-07-03 10:33 ` [PATCH v3 10/17] scsi-multipath: block PR commands John Garry
2026-07-03 12:03 ` sashiko-bot
2026-07-03 10:33 ` [PATCH v3 11/17] scsi-multipath: add delayed disk removal support John Garry
2026-07-03 12:08 ` sashiko-bot
2026-07-06 15:49 ` John Garry
2026-07-03 10:33 ` [PATCH v3 12/17] scsi: sd: add multipath disk class John Garry
2026-07-03 10:33 ` [PATCH v3 13/17] scsi: sd: support multipath disk John Garry
2026-07-03 12:24 ` sashiko-bot
2026-07-07 9:18 ` John Garry
2026-07-03 10:33 ` [PATCH v3 14/17] scsi: sd: add multipath disk attr groups John Garry
2026-07-03 12:25 ` sashiko-bot [this message]
2026-07-07 9:09 ` John Garry
2026-07-03 10:34 ` [PATCH v3 15/17] scsi: sd: add mpath_dev file John Garry
2026-07-03 12:43 ` sashiko-bot
2026-07-06 15:56 ` John Garry
2026-07-03 10:34 ` [PATCH v3 16/17] scsi: sd: add mpath_numa_nodes dev attribute John Garry
2026-07-03 12:44 ` sashiko-bot
2026-07-06 15:57 ` John Garry
2026-07-03 10:34 ` [PATCH v3 17/17] scsi: sd: add mpath_queue_depth " John Garry
2026-07-03 12:57 ` sashiko-bot
2026-07-06 15:59 ` John Garry
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=20260703122515.6B9AC1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=john.g.garry@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.