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: c4436c9149 ("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>
This commit is contained in:
Jiasheng Jiang 2023-06-19 17:28:02 +08:00 committed by Corey Minyard
parent 02210d5264
commit c5586d0f71
1 changed files with 5 additions and 0 deletions

View File

@ -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;