Skip to content

Commit 4788828

Browse files
windhlAlone0316
authored andcommitted
ethernet: sun: add check for the mdesc_grab()
[ Upstream commit 90de546d9a0b3c771667af18bb3f80567eabb89b ] 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 989fb3c commit 4788828

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
@@ -280,6 +280,9 @@ static int vsw_port_probe(struct vio_dev *vdev, const struct vio_device_id *id)
280280

281281
hp = mdesc_grab();
282282

283+
if (!hp)
284+
return -ENODEV;
285+
283286
rmac = mdesc_get_property(hp, vdev->mp, remote_macaddr_prop, &len);
284287
err = -ENODEV;
285288
if (!rmac) {

drivers/net/ethernet/sun/sunvnet.c

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

321321
hp = mdesc_grab();
322322

323+
if (!hp)
324+
return -ENODEV;
325+
323326
vp = vnet_find_parent(hp, vdev->mp, vdev);
324327
if (IS_ERR(vp)) {
325328
pr_err("Cannot find port parent vnet\n");

0 commit comments

Comments
 (0)