Skip to content

Commit

Permalink
net: ll_temac: check the return value of devm_kmalloc()
Browse files Browse the repository at this point in the history
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 <xkernel.wang@foxmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
x2018 authored and davem330 committed Feb 18, 2022
1 parent a1cdec5 commit b352c34
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/net/ethernet/xilinx/ll_temac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit b352c34

Please sign in to comment.