Skip to contentSkip to conversation

Fix mem leak in try_init_dmi() code

PATCH In review Jesper Juhl 2 participants 2 messages Jul 18, 2007 – Jul 19, 2007 IPMI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix mem leak in try_init_dmi() code

Hi there,

If we ever hit the "default:" case in the switch in try_init_dmi(), then we'll leak the storage allocated with kzalloc() and assigned to 'info'.

Note: patch has been compile tested only.

Please consider merging upstream :-)

---

 drivers/char/ipmi/ipmi_si_intf.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/drivers/char/ipmi/ipmi_si_intf.c
index 4edfdda..96d2f9e 100644

drivers/char/ipmi/ipmi_si_intf.c +0 -0
@@ -2050,6 +2050,7 @@ static __devinit void try_init_dmi(struct dmi_ipmi_data 

*ipmi_data)
info->si_type = SI_BT;
break;
default:
+ kfree(info);
return;
}

#1 lore raw

Indeed this is a problem, please merge. This is only called at init time and only happens if the BIOS screws something up, so the leak is slight and it is probably not worth sending to 2.6.22.x. The driver would not initialize the interface in the case, and I have no reports of this happening. I have booted and run tests on a system with this patch. Note that the original patch was munged by the mailer, here's a new one.

If we ever hit the "default:" case in the switch in try_init_dmi(), then we'll leak the storage allocated with kzalloc() and assigned to 'info'.

---

 drivers/char/ipmi/ipmi_si_intf.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/drivers/char/ipmi/ipmi_si_intf.c
index 4edfdda..96d2f9e 100644

drivers/char/ipmi/ipmi_si_intf.c +1 -0
@@ -2050,6 +2050,7 @@ static __devinit void try_init_dmi(struct dmi_ipmi_data *ipmi_data)
 		info->si_type = SI_BT;
 		break;
 	default:
+		kfree(info);
 		return;
 	}