Skip to content

Commit 75d53e8

Browse files
windhlgregkh
authored andcommitted
ethernet: sun: add check for the mdesc_grab()
[ Upstream commit 90de546 ] In vnet_port_probe() and vsw_port_probe(), we should check the return value of mdesc_grab() as it may return NULL which can caused NPD bugs. Fixes: 5d01fa0 ("ldmvsw: Add ldmvsw.c driver code") Fixes: 43fdf27 ("[SPARC64]: Abstract out mdesc accesses for better MD update handling.") Signed-off-by: Liang He <[email protected]> Reviewed-by: Piotr Raczynski <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 71c1fb8 commit 75d53e8

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

drivers/net/ethernet/sun/ldmvsw.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ static int vsw_port_probe(struct vio_dev *vdev, const struct vio_device_id *id)
289289

290290
hp = mdesc_grab();
291291

292+
if (!hp)
293+
return -ENODEV;
294+
292295
rmac = mdesc_get_property(hp, vdev->mp, remote_macaddr_prop, &len);
293296
err = -ENODEV;
294297
if (!rmac) {

drivers/net/ethernet/sun/sunvnet.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,9 @@ static int vnet_port_probe(struct vio_dev *vdev, const struct vio_device_id *id)
430430

431431
hp = mdesc_grab();
432432

433+
if (!hp)
434+
return -ENODEV;
435+
433436
vp = vnet_find_parent(hp, vdev->mp, vdev);
434437
if (IS_ERR(vp)) {
435438
pr_err("Cannot find port parent vnet\n");

0 commit comments

Comments
 (0)