Skip to contentSkip to conversation

ipmi: Fix error code in try_smi_init()

PATCH In review Dan Carpenter 2 participants 2 messages Mar 6, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ipmi: Fix error code in try_smi_init()

If platform_device_alloc() fails, then we should return -ENOMEM instead of returning success. I've also removed the "rv" initialization so that GCC can maybe detect if we forget to set it in the future.

---
v2: Don't initialize "rv" and fix a typo in the commit message

drivers/char/ipmi/ipmi_si_intf.c +2 -1
index f2a294f78892..c09b279cd55e 100644
@@ -2026,7 +2026,7 @@ int ipmi_si_add_smi(struct si_sm_io *io)
  */
 static int try_smi_init(struct smi_info *new_smi)
 {
-	int rv = 0;
+	int rv;
 	int i;
 	char *init_name = NULL;
 
@@ -2071,6 +2071,7 @@ static int try_smi_init(struct smi_info *new_smi)
 						      new_smi->intf_num);
 		if (!new_smi->pdev) {
 			pr_err(PFX "Unable to allocate platform device\n");
+			rv = -ENOMEM;
 			goto out_err;
 		}
 		new_smi->io.dev = &new_smi->pdev->dev;
Acked-by on v2 1/1
#1 lore raw
Quoted 7 lines · Dan Carpenter

If platform_device_alloc() fails, then we should return -ENOMEM instead of returning success. I've also removed the "rv" initialization so that GCC can maybe detect if we forget to set it in the future.

---
v2: Don't initialize "rv" and fix a typo in the commit message

This addresses my comment, so