Commit e420637b authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

w1_therm: Free the correct variable

The problem is that we change "p_args" to point to the middle of the
string so when we free it at the end of the function it's not freeing
the same pointer that we originally allocated.

Fixes: e2c94d6f ("w1_therm: adding alarm sysfs entry")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200520120019.GA172354@mwandaSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c9d7e3da
...@@ -1526,8 +1526,9 @@ static ssize_t alarms_store(struct device *device, ...@@ -1526,8 +1526,9 @@ static ssize_t alarms_store(struct device *device,
int temp, ret = -EINVAL; int temp, ret = -EINVAL;
char *token = NULL; char *token = NULL;
s8 tl, th, tt; /* 1 byte per value + temp ring order */ s8 tl, th, tt; /* 1 byte per value + temp ring order */
char *p_args = kmalloc(size, GFP_KERNEL); char *p_args, *orig;
p_args = orig = kmalloc(size, GFP_KERNEL);
/* Safe string copys as buf is const */ /* Safe string copys as buf is const */
if (!p_args) { if (!p_args) {
dev_warn(device, dev_warn(device,
...@@ -1611,7 +1612,7 @@ static ssize_t alarms_store(struct device *device, ...@@ -1611,7 +1612,7 @@ static ssize_t alarms_store(struct device *device,
free_m: free_m:
/* free allocated memory */ /* free allocated memory */
kfree(p_args); kfree(orig);
return size; return size;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment