aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2018-01-22 04:38:57 -0500
committerJon Mason <jdmason@kudzu.us>2018-01-28 22:17:24 -0500
commit2e2bc5a9a300261853303c006b7c29faafc64221 (patch)
tree8fd676caf858363541e4d64130bda58c9faa0047
parent1536dc063e82090c5da65ddd94b1da1b38bfab43 (diff)
NTB: ntb_tool: fix memory leak on 'buf' on error exit path
Currently there is a memory leak on buf when the call to ntb_mw_get_align fails. Add an exit err label and jump to this so that kfree on buf frees the memory. Detected by CoverityScan, CID#1464286 ("Resource leak") Fixes: d637628ce00c ("NTB: ntb_tool: Add full multi-port NTB API support") Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Serge Semin <fancer.lancer@gmail.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
-rw-r--r--drivers/ntb/test/ntb_tool.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/ntb/test/ntb_tool.c b/drivers/ntb/test/ntb_tool.c
index 920fc9b161b0..d592c0ffbd19 100644
--- a/drivers/ntb/test/ntb_tool.c
+++ b/drivers/ntb/test/ntb_tool.c
@@ -659,7 +659,7 @@ static ssize_t tool_mw_trans_read(struct file *filep, char __user *ubuf,
659 ret = ntb_mw_get_align(inmw->tc->ntb, inmw->pidx, inmw->widx, 659 ret = ntb_mw_get_align(inmw->tc->ntb, inmw->pidx, inmw->widx,
660 &addr_align, &size_align, &size_max); 660 &addr_align, &size_align, &size_max);
661 if (ret) 661 if (ret)
662 return ret; 662 goto err;
663 663
664 off += scnprintf(buf + off, buf_size - off, 664 off += scnprintf(buf + off, buf_size - off,
665 "Inbound MW \t%d\n", 665 "Inbound MW \t%d\n",
@@ -694,6 +694,8 @@ static ssize_t tool_mw_trans_read(struct file *filep, char __user *ubuf,
694 &size_max); 694 &size_max);
695 695
696 ret = simple_read_from_buffer(ubuf, size, offp, buf, off); 696 ret = simple_read_from_buffer(ubuf, size, offp, buf, off);
697
698err:
697 kfree(buf); 699 kfree(buf);
698 700
699 return ret; 701 return ret;