From: Xiaoke Wang Date: Fri, 18 Feb 2022 02:19:39 +0000 (+0800) Subject: net: ll_temac: check the return value of devm_kmalloc() X-Git-Tag: baikal/mips/sdk6.1~6373^2~31 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=12f21cd035bc1538b041949922c7059c72194c42;p=kernel.git net: ll_temac: check the return value of devm_kmalloc() 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. Fixes: abb9098d3898 ("net: ll_temac: Support indirect_mutex share within TEMAC IP") Signed-off-by: Xiaoke Wang Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c index b900ab5aef2a8..64c7e26c3b754 100644 --- a/drivers/net/ethernet/xilinx/ll_temac_main.c +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c @@ -1433,6 +1433,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); }