summaryrefslogtreecommitdiffstats
path: root/drivers/char/ipmi
diff options
context:
space:
mode:
authorJiasheng Jiang <jiasheng@iscas.ac.cn>2023-06-19 11:28:02 +0200
committerCorey Minyard <minyard@acm.org>2023-06-19 18:40:38 +0200
commitc5586d0f711e9744d0cade39b0c4a2d116a333ca (patch)
treee0e13134c6c90aa67b4c3d40a53f03edb2000bc3 /drivers/char/ipmi
parentdt-bindings: ipmi: aspeed,ast2400-kcs-bmc: drop unneeded quotes (diff)
downloadlinux-c5586d0f711e9744d0cade39b0c4a2d116a333ca.tar.xz
linux-c5586d0f711e9744d0cade39b0c4a2d116a333ca.zip
ipmi:ssif: Add check for kstrdup
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> Message-Id: <20230619092802.35384-1-jiasheng@iscas.ac.cn> Signed-off-by: Corey Minyard <minyard@acm.org>
Diffstat (limited to 'drivers/char/ipmi')
-rw-r--r--drivers/char/ipmi/ipmi_ssif.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index c6c9bcf6bf55..07cfde579cfb 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;