瀏覽代碼

hwmon: (coretemp) Avoid leaving around dangling pointer

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.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Acked-by: Jean Delvare <khali@linux-fr.org>
Guenter Roeck 14 年之前
父節點
當前提交
20ecb499f6
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      drivers/hwmon/coretemp.c

+ 1 - 0
drivers/hwmon/coretemp.c

@@ -506,6 +506,7 @@ static int create_core_data(struct platform_device *pdev,
 
 	return 0;
 exit_free:
+	pdata->core_data[attr_no] = NULL;
 	kfree(tdata);
 	return err;
 }