diff options
Diffstat (limited to 'kernel/trace/blktrace.c')
-rw-r--r-- | kernel/trace/blktrace.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 947c5b3f90c4..921ef5d1f0ba 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
@@ -327,10 +327,10 @@ static ssize_t blk_msg_write(struct file *filp, const char __user *buffer, | |||
327 | char *msg; | 327 | char *msg; |
328 | struct blk_trace *bt; | 328 | struct blk_trace *bt; |
329 | 329 | ||
330 | if (count > BLK_TN_MAX_MSG) | 330 | if (count >= BLK_TN_MAX_MSG) |
331 | return -EINVAL; | 331 | return -EINVAL; |
332 | 332 | ||
333 | msg = kmalloc(count, GFP_KERNEL); | 333 | msg = kmalloc(count + 1, GFP_KERNEL); |
334 | if (msg == NULL) | 334 | if (msg == NULL) |
335 | return -ENOMEM; | 335 | return -ENOMEM; |
336 | 336 | ||
@@ -339,6 +339,7 @@ static ssize_t blk_msg_write(struct file *filp, const char __user *buffer, | |||
339 | return -EFAULT; | 339 | return -EFAULT; |
340 | } | 340 | } |
341 | 341 | ||
342 | msg[count] = '\0'; | ||
342 | bt = filp->private_data; | 343 | bt = filp->private_data; |
343 | __trace_note_message(bt, "%s", msg); | 344 | __trace_note_message(bt, "%s", msg); |
344 | kfree(msg); | 345 | kfree(msg); |
@@ -642,7 +643,7 @@ static void blk_add_trace_rq(struct request_queue *q, struct request *rq, | |||
642 | if (blk_pc_request(rq)) { | 643 | if (blk_pc_request(rq)) { |
643 | what |= BLK_TC_ACT(BLK_TC_PC); | 644 | what |= BLK_TC_ACT(BLK_TC_PC); |
644 | __blk_add_trace(bt, 0, rq->data_len, rw, what, rq->errors, | 645 | __blk_add_trace(bt, 0, rq->data_len, rw, what, rq->errors, |
645 | sizeof(rq->cmd), rq->cmd); | 646 | rq->cmd_len, rq->cmd); |
646 | } else { | 647 | } else { |
647 | what |= BLK_TC_ACT(BLK_TC_FS); | 648 | what |= BLK_TC_ACT(BLK_TC_FS); |
648 | __blk_add_trace(bt, rq->hard_sector, rq->hard_nr_sectors << 9, | 649 | __blk_add_trace(bt, rq->hard_sector, rq->hard_nr_sectors << 9, |
@@ -1376,12 +1377,12 @@ static int blk_trace_str2mask(const char *str) | |||
1376 | { | 1377 | { |
1377 | int i; | 1378 | int i; |
1378 | int mask = 0; | 1379 | int mask = 0; |
1379 | char *s, *token; | 1380 | char *buf, *s, *token; |
1380 | 1381 | ||
1381 | s = kstrdup(str, GFP_KERNEL); | 1382 | buf = kstrdup(str, GFP_KERNEL); |
1382 | if (s == NULL) | 1383 | if (buf == NULL) |
1383 | return -ENOMEM; | 1384 | return -ENOMEM; |
1384 | s = strstrip(s); | 1385 | s = strstrip(buf); |
1385 | 1386 | ||
1386 | while (1) { | 1387 | while (1) { |
1387 | token = strsep(&s, ","); | 1388 | token = strsep(&s, ","); |
@@ -1402,7 +1403,7 @@ static int blk_trace_str2mask(const char *str) | |||
1402 | break; | 1403 | break; |
1403 | } | 1404 | } |
1404 | } | 1405 | } |
1405 | kfree(s); | 1406 | kfree(buf); |
1406 | 1407 | ||
1407 | return mask; | 1408 | return mask; |
1408 | } | 1409 | } |