Skip to content

Commit

Permalink
ipmi:ssif: Add check for kstrdup
Browse files Browse the repository at this point in the history
[ Upstream commit c5586d0 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
JiangJias authored and gregkh committed Sep 13, 2023
1 parent abbd28d commit 2e7d90a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/char/ipmi/ipmi_ssif.c
Expand Up @@ -1603,6 +1603,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 2e7d90a

Please sign in to comment.