From: Greg KH <gregkh@linuxfoundation.org>
To: Tzung-Bi Shih <tzungbi@kernel.org>
Cc: "James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] scsi: core: Correct wrong kfree() usage for `kobj->name`
Date: Fri, 16 Jan 2026 10:00:11 +0100 [thread overview]
Message-ID: <2026011614-exile-raisin-0ec4@gregkh> (raw)
In-Reply-To: <20260116081359.353256-1-tzungbi@kernel.org>
On Fri, Jan 16, 2026 at 08:13:59AM +0000, Tzung-Bi Shih wrote:
> `kobj->name` should be freed by kfree_const()[1][2]. Correct it.
>
> [1] https://elixir.bootlin.com/linux/v6.18/source/lib/kasprintf.c#L41
> [2] https://elixir.bootlin.com/linux/v6.18/source/lib/kobject.c#L695
>
> Cc: stable@vger.kernel.org
> Fixes: b49493f99690 ("Fix a memory leak in scsi_host_dev_release()")
> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
> ---
> drivers/scsi/hosts.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
> index e047747d4ecf..50ec782cf9f4 100644
> --- a/drivers/scsi/hosts.c
> +++ b/drivers/scsi/hosts.c
> @@ -373,7 +373,7 @@ static void scsi_host_dev_release(struct device *dev)
> * name as well as the proc dir structure are leaked.
> */
> scsi_proc_hostdir_rm(shost->hostt);
> - kfree(dev_name(&shost->shost_dev));
> + kfree_const(dev_name(&shost->shost_dev));
Shouldn't the struct device name be freed by the driver core for this
device when it goes out of scope? Why is it being manually freed here
at all?
thanks,
greg k-h
next prev parent reply other threads:[~2026-01-16 9:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 8:13 [PATCH] scsi: core: Correct wrong kfree() usage for `kobj->name` Tzung-Bi Shih
2026-01-16 9:00 ` Greg KH [this message]
2026-01-16 9:37 ` Tzung-Bi Shih
2026-01-16 10:50 ` Greg KH
2026-01-17 19:48 ` Tzung-Bi Shih
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=2026011614-exile-raisin-0ec4@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=stable@vger.kernel.org \
--cc=tzungbi@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