Skip to contentSkip to conversation

hwmon: (coretemp) Avoid leaving around

PATCH In review Guenter Roeck 2 participants 3 messages Sep 24, 2011 – Sep 28, 2011

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

PATCH 1/1 hwmon: (coretemp) Avoid leaving around

Storing the struct temp_data pointer allocated from create_core_data() when returning an error has the potential of leaving around a pointer to freed memory. Reset it to NULL for error returns.

---
I want to send the pending patches to Linus, and include a fix for the problem reported by Jan. So here it is.

 drivers/hwmon/coretemp.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/hwmon/coretemp.c +1 -0
index 44b2391..5100b01 100644
@@ -508,6 +508,7 @@ static int create_core_data(struct platform_device *pdev,
 
 	return 0;
 exit_free:
+	pdata->core_data[attr_no] = NULL;
 	kfree(tdata);
 	return err;
 }
Signature · 7 lines
1.7.3.1


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Acked-by on v1 1/1
#1 lore raw

Hi Guenter,

Once again sorry for the late review. At this rate I'm going to add this to my signature :(

Quoted 18 lines · Guenter Roeck

Storing the struct temp_data pointer allocated from create_core_data() when returning an error has the potential of leaving around a pointer to freed memory. Reset it to NULL for error returns.

---
I want to send the pending patches to Linus, and include a fix for the problem reported by Jan. So here it is.

 drivers/hwmon/coretemp.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/hwmon/coretemp.c +0 -0
index 44b2391..5100b01 100644

drivers/hwmon/coretemp.c static int create_core_data(struct platform_device *pdev, · line 514

Quoted 7 lines
drivers/hwmon/coretemp.c +1 -0
@@ -508,6 +508,7 @@ static int create_core_data(struct platform_device *pdev,
 
 	return 0;
 exit_free:
+	pdata->core_data[attr_no] = NULL;
 	kfree(tdata);
 	return err;
 }

Yes, obviously correct and the right thing to do.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#2 lore raw
In reply to Guenter Roeck
Quoted 34 lines · Jean Delvare

Hi Guenter,

Once again sorry for the late review. At this rate I'm going to add this to my signature :(

Quoted 18 lines · Guenter Roeck

Storing the struct temp_data pointer allocated from create_core_data() when returning an error has the potential of leaving around a pointer to freed memory. Reset it to NULL for error returns.

---
I want to send the pending patches to Linus, and include a fix for the problem reported by Jan. So here it is.

 drivers/hwmon/coretemp.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/hwmon/coretemp.c +0 -0
index 44b2391..5100b01 100644

drivers/hwmon/coretemp.c static int create_core_data(struct platform_device *pdev, · line 514

Quoted 7 lines
drivers/hwmon/coretemp.c +1 -0
@@ -508,6 +508,7 @@ static int create_core_data(struct platform_device *pdev,
 
 	return 0;
 exit_free:
+	pdata->core_data[attr_no] = NULL;
 	kfree(tdata);
 	return err;
 }

Yes, obviously correct and the right thing to do.

Quoted 2 lines

Better late than never ... thanks, applied.

Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors