From: Corey Minyard <corey@minyard.net>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: zhangjiao2 <zhangjiao2@cmss.chinamobile.com>,
openipmi-developer@lists.sourceforge.net,
linux-kernel@vger.kernel.org, minyard@acm.org
Subject: Re: [Openipmi-developer] [PATCH] ipmi: Use devm_kasprintf
Date: Wed, 4 Sep 2024 16:49:24 -0500 [thread overview]
Message-ID: <ZtjV5DoZXPYM1NJx@mail.minyard.net> (raw)
In-Reply-To: <004f59c4-7401-473f-b15f-02aa5151374b@wanadoo.fr>
On Wed, Sep 04, 2024 at 07:41:32PM +0200, Christophe JAILLET via Openipmi-developer wrote:
> Le 04/09/2024 à 06:12, zhangjiao2 a écrit :
> > From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> >
> > Use devm_kasprintf to simplify code.
>
> Hi,
>
> I don't think that it is correct because __ipmi_bmc_register() is not a
> probe function ans is not called from a probe function. So it is really
> unlikely that a devm_ function is correct.
>
> The kasprintf() you are removing is balanced by a kfree() in
> __ipmi_bmc_unregister().
> So you patch would lead to a potential double-free issue.
Yes, this is incorrect from a number of points of view.
-corey
>
> CJ
>
> >
> > Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> > ---
> > drivers/char/ipmi/ipmi_msghandler.c | 9 ++-------
> > 1 file changed, 2 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> > index e12b531f5c2f..5d78b1fe49a8 100644
> > --- a/drivers/char/ipmi/ipmi_msghandler.c
> > +++ b/drivers/char/ipmi/ipmi_msghandler.c
> > @@ -3213,7 +3213,7 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,
> > if (intf_num == -1)
> > intf_num = intf->intf_num;
> > - intf->my_dev_name = kasprintf(GFP_KERNEL, "ipmi%d", intf_num);
> > + intf->my_dev_name = devm_kasprintf(intf->si_dev, GFP_KERNEL, "ipmi%d", intf_num);
> > if (!intf->my_dev_name) {
> > rv = -ENOMEM;
> > dev_err(intf->si_dev, "Unable to allocate link from BMC: %d\n",
> > @@ -3226,7 +3226,7 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,
> > if (rv) {
> > dev_err(intf->si_dev, "Unable to create symlink to bmc: %d\n",
> > rv);
> > - goto out_free_my_dev_name;
> > + goto out_unlink1;
> > }
> > intf->bmc_registered = true;
> > @@ -3237,11 +3237,6 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,
> > intf->in_bmc_register = false;
> > return rv;
> > -
> > -out_free_my_dev_name:
> > - kfree(intf->my_dev_name);
> > - intf->my_dev_name = NULL;
> > -
> > out_unlink1:
> > sysfs_remove_link(&intf->si_dev->kobj, "bmc");
>
>
>
> _______________________________________________
> Openipmi-developer mailing list
> Openipmi-developer@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openipmi-developer
prev parent reply other threads:[~2024-09-04 21:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-04 4:12 [PATCH] ipmi: Use devm_kasprintf zhangjiao2
2024-09-04 17:41 ` Christophe JAILLET
2024-09-04 21:49 ` Corey Minyard [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=ZtjV5DoZXPYM1NJx@mail.minyard.net \
--to=corey@minyard.net \
--cc=christophe.jaillet@wanadoo.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=minyard@acm.org \
--cc=openipmi-developer@lists.sourceforge.net \
--cc=zhangjiao2@cmss.chinamobile.com \
/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