hwmon: (coretemp) Avoid leaving around dangling pointer
authorGuenter Roeck <guenter.roeck@ericsson.com>
Sat, 24 Sep 2011 22:27:04 +0000 (15:27 -0700)
committerGuenter Roeck <guenter.roeck@ericsson.com>
Wed, 28 Sep 2011 15:19:21 +0000 (08:19 -0700)
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>
drivers/hwmon/coretemp.c

index cf5b1de32c0a01d9d42018f4041b0550661c7acd..9323837866422c181df7bee75b48cd7693db7bc2 100644 (file)
@@ -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;
 }