Skip to contentSkip to conversation

ipmi: Fix NULL pointer dereference in ssif_probe

PATCH In review Gustavo A. R. Silva 2 participants 3 messages Aug 31, 2018 IPMI

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ipmi: Fix NULL pointer dereference in ssif_probe

There is a potential execution path in which function ssif_info_find() returns NULL, hence there is a NULL pointer dereference when accessing pointer *addr_info*

Fix this by null checking *addr_info* before dereferencing it.

Addresses-Coverity-ID: 1473145 ("Explicit null dereferenced")

Fixes e333054a91d1 ("ipmi: Fix I2C client removal in the SSIF driver")

---
Changes in v2:
- Fix typo in commit log.

 drivers/char/ipmi/ipmi_ssif.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/ipmi/ipmi_ssif.c +3 -1
index 2ff3679..764d305 100644
@@ -1641,7 +1641,9 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
 
  out:
 	if (rv) {
-		addr_info->client = NULL;
+		if (addr_info)
+			addr_info->client = NULL;
+
 		dev_err(&client->dev, "Unable to start IPMI SSIF: %d\n", rv);
 		kfree(ssif_info);
 	}
Signature · 1 line
2.7.4
#1 lore raw
Quoted 5 lines · Gustavo A. R. Silva

There is a potential execution path in which function ssif_info_find() returns NULL, hence there is a NULL pointer dereference when accessing pointer *addr_info*

Fix this by null checking *addr_info* before dereferencing it.

Thanks for catching this quickly, before it went out.  It's merged into my next tree.

-corey

Quoted 25 lines

Addresses-Coverity-ID: 1473145 ("Explicit null dereferenced")

Fixes e333054a91d1 ("ipmi: Fix I2C client removal in the SSIF driver")

---
Changes in v2:
- Fix typo in commit log.

  drivers/char/ipmi/ipmi_ssif.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/ipmi/ipmi_ssif.c +3 -1
index 2ff3679..764d305 100644
@@ -1641,7 +1641,9 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
 
   out:
  	if (rv) {
-		addr_info->client = NULL;
+		if (addr_info)
+			addr_info->client = NULL;
+
  		dev_err(&client->dev, "Unable to start IPMI SSIF: %d\n", rv);
  		kfree(ssif_info);
  	}
#2 lore raw
Quoted 9 lines · Corey Minyard
Quoted 5 lines · Gustavo A. R. Silva

There is a potential execution path in which function ssif_info_find() returns NULL, hence there is a NULL pointer dereference when accessing pointer *addr_info*

Fix this by null checking *addr_info* before dereferencing it.

Thanks for catching this quickly, before it went out.  It's merged into my next tree.

Glad to help. :)

Thanks
--
Gustavo