* [PATCH] ipmi:ssif: Add check for kstrdup
@ 2023-06-19 9:28 Jiasheng Jiang
2023-06-19 16:40 ` Corey Minyard
0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2023-06-19 9:28 UTC (permalink / raw)
To: minyard, kamlakantp; +Cc: openipmi-developer, linux-kernel, Jiasheng Jiang
Add check for the return value of kstrdup() and return the error
if it fails in order to avoid NULL pointer dereference.
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ipmi:ssif: Add check for kstrdup
2023-06-19 9:28 [PATCH] ipmi:ssif: Add check for kstrdup Jiasheng Jiang
@ 2023-06-19 16:40 ` Corey Minyard
0 siblings, 0 replies; 2+ messages in thread
From: Corey Minyard @ 2023-06-19 16:40 UTC (permalink / raw)
To: Jiasheng Jiang; +Cc: kamlakantp, openipmi-developer, linux-kernel
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-19 16:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-19 9:28 [PATCH] ipmi:ssif: Add check for kstrdup Jiasheng Jiang
2023-06-19 16:40 ` Corey Minyard
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.