blktrace: pass the right pointer to kfree()
Impact: fix kfree crash with non-standard act_mask string If passing a string with leading white spaces to strstrip(), the returned ptr != the original ptr. This bug was introduced by me. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Cc: Jens Axboe <jens.axboe@oracle.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> LKML-Reference: <49DD694C.8020902@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
@@ -1377,12 +1377,12 @@ static int blk_trace_str2mask(const char *str)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
char *s, *token;
|
char *buf, *s, *token;
|
||||||
|
|
||||||
s = kstrdup(str, GFP_KERNEL);
|
buf = kstrdup(str, GFP_KERNEL);
|
||||||
if (s == NULL)
|
if (buf == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
s = strstrip(s);
|
s = strstrip(buf);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
token = strsep(&s, ",");
|
token = strsep(&s, ",");
|
||||||
@@ -1403,7 +1403,7 @@ static int blk_trace_str2mask(const char *str)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
kfree(s);
|
kfree(buf);
|
||||||
|
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user