ntb_tool: check null return of devm_kcalloc in tool_init_mws
PATCH 1/1 ntb_tool: check null return of devm_kcalloc in tool_init_mws
devm_kcalloc may fails, tc->peers[pidx].outmws might be null and will cause null pointer dereference later.
--- drivers/ntb/test/ntb_tool.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/ntb/test/ntb_tool.c +2 -0
@@ -998,6 +998,8 @@ static int tool_init_mws(struct tool_ctx *tc) tc->peers[pidx].outmws =devm_kcalloc (&tc->ntb->dev, tc->peers[pidx].outmw_cnt,sizeof (*tc->peers[pidx].outmws),GFP_KERNEL ); +if (tc->peers[pidx].outmws ==NULL ) +return -ENOMEM ;for (widx =0 ; widx < tc->peers[pidx].outmw_cnt; widx++) { tc->peers[pidx].outmws[widx].pidx = pidx;
Signature · 1 line
2.34.1
Quoted 4 lines · Kang Chen
devm_kcallocmay fails, tc->peers[pidx].outmws might be null and will cause null pointer dereference later.Signed-off-by Kang Chen <[email protected]>
Quoted 17 lines
--- drivers/ntb/test/ntb_tool.c | 2 ++ 1 file changed, 2 insertions(+)drivers/ntb/test/ntb_tool.c +2
-0@@ -998,6 +998,8 @@ static int tool_init_mws(struct tool_ctx *tc) tc->peers[pidx].outmws =devm_kcalloc (&tc->ntb->dev, tc->peers[pidx].outmw_cnt,sizeof (*tc->peers[pidx].outmws),GFP_KERNEL ); +if (tc->peers[pidx].outmws ==NULL ) +return -ENOMEM ;for (widx =0 ; widx < tc->peers[pidx].outmw_cnt; widx++) { tc->peers[pidx].outmws[widx].pidx = pidx;
Quoted 4 lines · Kang Chen
devm_kcallocmay fails, tc->peers[pidx].outmws might be null and will cause null pointer dereference later.Signed-off-by Kang Chen <[email protected]>
Please add the fixes tag:
so the patch could be noticeable by the stable kernel maintainers.
Other than that looks good.
* Please don't forget to add the Rb-tags on v2.
-Serge(y)
Quoted 21 lines
--- drivers/ntb/test/ntb_tool.c | 2 ++ 1 file changed, 2 insertions(+)drivers/ntb/test/ntb_tool.c +2
-0@@ -998,6 +998,8 @@ static int tool_init_mws(struct tool_ctx *tc) tc->peers[pidx].outmws =devm_kcalloc (&tc->ntb->dev, tc->peers[pidx].outmw_cnt,sizeof (*tc->peers[pidx].outmws),GFP_KERNEL ); +if (tc->peers[pidx].outmws ==NULL ) +return -ENOMEM ;for (widx =0 ; widx < tc->peers[pidx].outmw_cnt; widx++) { tc->peers[pidx].outmws[widx].pidx = pidx;Signature · 1 line
2.34.1
PATCH v2 1/1 ntb_tool: check null return of devm_kcalloc in tool_init_mws
devm_kcalloc may fails, tc->peers[pidx].outmws might be null and will cause null pointer dereference later.
---
v2 -> v1: add Fixes and Reviewed-by tags
drivers/ntb/test/ntb_tool.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/ntb/test/ntb_tool.c +2 -0
@@ -998,6 +998,8 @@ static int tool_init_mws(struct tool_ctx *tc) tc->peers[pidx].outmws =devm_kcalloc (&tc->ntb->dev, tc->peers[pidx].outmw_cnt,sizeof (*tc->peers[pidx].outmws),GFP_KERNEL ); +if (tc->peers[pidx].outmws ==NULL ) +return -ENOMEM ;for (widx =0 ; widx < tc->peers[pidx].outmw_cnt; widx++) { tc->peers[pidx].outmws[widx].pidx = pidx;
Signature · 1 line
2.34.1
Dave Jiang
maintainerQuoted 6 lines · Kang Chen
devm_kcallocmay fails, tc->peers[pidx].outmws might be null and will cause null pointer dereference later.Fixes 7f46c8b3a552 ("NTB: ntb_tool: Add full multi-port NTB API support")Signed-off-by Kang Chen <[email protected]>Reviewed-by Serge Semin <[email protected]>
You forgot to pick up my review tag. I do recommend using the tool 'b4'. It picks up all the tags for you and works rather well.
Quoted 19 lines
---
v2 -> v1: add Fixes and Reviewed-by tagsdrivers/ntb/test/ntb_tool.c | 2 ++ 1 file changed, 2 insertions(+)drivers/ntb/test/ntb_tool.c +2
-0@@ -998,6 +998,8 @@ static int tool_init_mws(struct tool_ctx *tc) tc->peers[pidx].outmws =devm_kcalloc (&tc->ntb->dev, tc->peers[pidx].outmw_cnt,sizeof (*tc->peers[pidx].outmws),GFP_KERNEL ); +if (tc->peers[pidx].outmws ==NULL ) +return -ENOMEM ;for (widx =0 ; widx < tc->peers[pidx].outmw_cnt; widx++) { tc->peers[pidx].outmws[widx].pidx = pidx;
What a cool tool, thanks for your suggestions.
Quoted 33 lines · Dave Jiang
Quoted 6 lines · Kang Chen
devm_kcallocmay fails, tc->peers[pidx].outmws might be null and will cause null pointer dereference later.Fixes 7f46c8b3a552 ("NTB: ntb_tool: Add full multi-port NTB API support")Signed-off-by Kang Chen <[email protected]>Reviewed-by Serge Semin <[email protected]>You forgot to pick up my review tag. I do recommend using the tool 'b4'. It picks up all the tags for you and works rather well.
Quoted 19 lines
---
v2 -> v1: add Fixes and Reviewed-by tagsdrivers/ntb/test/ntb_tool.c | 2 ++ 1 file changed, 2 insertions(+)drivers/ntb/test/ntb_tool.c +2
-0@@ -998,6 +998,8 @@ static int tool_init_mws(struct tool_ctx *tc) tc->peers[pidx].outmws =devm_kcalloc (&tc->ntb->dev, tc->peers[pidx].outmw_cnt,sizeof (*tc->peers[pidx].outmws),GFP_KERNEL ); +if (tc->peers[pidx].outmws ==NULL ) +return -ENOMEM ;for (widx =0 ; widx < tc->peers[pidx].outmw_cnt; widx++) { tc->peers[pidx].outmws[widx].pidx = pidx;
PATCH v3 1/1 ntb_tool: check null return of devm_kcalloc in tool_init_mws
From: Kang Chen <[email protected]>
devm_kcalloc may fails, tc->peers[pidx].outmws might be null and will cause null pointer dereference later.
---
v3 -> v2: add Reviewed-by tag
v2 -> v1: add Fixes and Reviewed-by tags
drivers/ntb/test/ntb_tool.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/ntb/test/ntb_tool.c +2 -0
@@ -998,6 +998,8 @@ static int tool_init_mws(struct tool_ctx *tc) tc->peers[pidx].outmws =devm_kcalloc (&tc->ntb->dev, tc->peers[pidx].outmw_cnt,sizeof (*tc->peers[pidx].outmws),GFP_KERNEL ); +if (tc->peers[pidx].outmws ==NULL ) +return -ENOMEM ;for (widx =0 ; widx < tc->peers[pidx].outmw_cnt; widx++) { tc->peers[pidx].outmws[widx].pidx = pidx;
Signature · 1 line
2.34.1