Skip to content

Commit

Permalink
hwmon: (coretemp) Avoid leaving around dangling pointer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Guenter Roeck committed Sep 28, 2011
1 parent 0eb9782 commit 20ecb49
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/hwmon/coretemp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 20ecb49

Please sign in to comment.