mirror of
https://github.com/torvalds/linux.git
synced 2024-12-02 17:11:33 +00:00
net: dsa: loop: Check for memory allocation failure
If 'devm_kzalloc' fails, a NULL pointer will be dereferenced.
Return -ENOMEM instead, as done for some other memory allocation just a
few lines above.
Fixes: 98cd1552ea
("net: dsa: Mock-up driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d62844a825
commit
8ce7aaaa97
@ -256,6 +256,9 @@ static int dsa_loop_drv_probe(struct mdio_device *mdiodev)
|
||||
return -ENOMEM;
|
||||
|
||||
ps = devm_kzalloc(&mdiodev->dev, sizeof(*ps), GFP_KERNEL);
|
||||
if (!ps)
|
||||
return -ENOMEM;
|
||||
|
||||
ps->netdev = dev_get_by_name(&init_net, pdata->netdev);
|
||||
if (!ps->netdev)
|
||||
return -EPROBE_DEFER;
|
||||
|
Loading…
Reference in New Issue
Block a user