net: ll_temac: check the return value of devm_kmalloc()
PATCH v2 1/1 net: ll_temac: check the return value of devm_kmalloc()
From: Xiaoke Wang <[email protected]>
devm_kmalloc() returns a pointer to allocated memory on success, NULL on failure. While lp->indirect_lock is allocated by devm_kmalloc() without proper check. It is better to check the value of it to prevent potential wrong memory access.
---
Changelog
v1-v2: add Fixes tag and remove redundant err message.
drivers/net/ethernet/xilinx/ll_temac_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/xilinx/ll_temac_main.c +2 -0
@@ -1427,6 +1427,8 @@ static int temac_probe(struct platform_device *pdev) lp->indirect_lock =devm_kmalloc (&pdev->dev,sizeof (*lp->indirect_lock),GFP_KERNEL ); +if (!lp->indirect_lock) +return -ENOMEM ;spin_lock_init (lp->indirect_lock); }
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:
Quoted 8 lines · On Fri, 18 Feb 2022 10:19:39 +0800 you wrote:
From: Xiaoke Wang <[email protected]>
devm_kmalloc()returns a pointer to allocated memory on success, NULL on failure. Whilelp->indirect_lockis allocated bydevm_kmalloc()without proper check. It is better to check the value of it to prevent potential wrong memory access.[...]
Here is the summary with links:
- [v2] net: ll_temac: check the return value of devm_kmalloc()
https://git.kernel.org/netdev/net/c/b352c3465bb8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html