Skip to content

Commit b352c34

Browse files
x2018davem330
authored andcommitted
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: f14f5c1 ("net: ll_temac: Support indirect_mutex share within TEMAC IP") Signed-off-by: Xiaoke Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a1cdec5 commit b352c34

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/net/ethernet/xilinx/ll_temac_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,8 @@ static int temac_probe(struct platform_device *pdev)
14331433
lp->indirect_lock = devm_kmalloc(&pdev->dev,
14341434
sizeof(*lp->indirect_lock),
14351435
GFP_KERNEL);
1436+
if (!lp->indirect_lock)
1437+
return -ENOMEM;
14361438
spin_lock_init(lp->indirect_lock);
14371439
}
14381440

0 commit comments

Comments
 (0)