Skip to content

Commit

Permalink
ipmi:ssif: Add check for kstrdup
Browse files Browse the repository at this point in the history
Add check for the return value of kstrdup() and return the error
if it fails in order to avoid NULL pointer dereference.

Fixes: c4436c9 ("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>
  • Loading branch information
JiangJias authored and cminyard committed Jun 19, 2023
1 parent 02210d5 commit c5586d0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/char/ipmi/ipmi_ssif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c5586d0

Please sign in to comment.