mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Corey Minyard <minyard@acm.org>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Cc: kamlakantp@marvell.com, openipmi-developer@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ipmi:ssif: Add check for kstrdup
Date: Mon, 19 Jun 2023 11:40:59 -0500	[thread overview]
Message-ID: <ZJCFG3o4JL/OL9WU@mail.minyard.net> (raw)
In-Reply-To: <20230619092802.35384-1-jiasheng@iscas.ac.cn>

On Mon, Jun 19, 2023 at 05:28:02PM +0800, Jiasheng Jiang wrote:
> Add check for the return value of kstrdup() and return the error
> if it fails in order to avoid NULL pointer dereference.

Thanks, this is in my next tree.

-corey

> 
> Fixes: c4436c9149c5 ("ipmi_ssif: avoid registering duplicate ssif interface")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  drivers/char/ipmi/ipmi_ssif.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
> index 3b921c78ba08..3b87a2726e99 100644
> --- a/drivers/char/ipmi/ipmi_ssif.c
> +++ b/drivers/char/ipmi/ipmi_ssif.c
> @@ -1600,6 +1600,11 @@ static int ssif_add_infos(struct i2c_client *client)
>  	info->addr_src = SI_ACPI;
>  	info->client = client;
>  	info->adapter_name = kstrdup(client->adapter->name, GFP_KERNEL);
> +	if (!info->adapter_name) {
> +		kfree(info);
> +		return -ENOMEM;
> +	}
> +
>  	info->binfo.addr = client->addr;
>  	list_add_tail(&info->link, &ssif_infos);
>  	return 0;
> -- 
> 2.25.1
> 

      reply	other threads:[~2023-06-19 16:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19  9:28 Jiasheng Jiang
2023-06-19 16:40 ` 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=ZJCFG3o4JL/OL9WU@mail.minyard.net \
    --to=minyard@acm.org \
    --cc=jiasheng@iscas.ac.cn \
    --cc=kamlakantp@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openipmi-developer@lists.sourceforge.net \
    /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®