Skip to content

Commit

Permalink
ethernet: sun: add check for the mdesc_grab()
Browse files Browse the repository at this point in the history
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 <windhl@126.com>
Reviewed-by: Piotr Raczynski <piotr.raczynski@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Liang He authored and David S. Miller committed Mar 17, 2023
1 parent 0c98b8b commit 90de546
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/ethernet/sun/ldmvsw.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ static int vsw_port_probe(struct vio_dev *vdev, const struct vio_device_id *id)

hp = mdesc_grab();

if (!hp)
return -ENODEV;

rmac = mdesc_get_property(hp, vdev->mp, remote_macaddr_prop, &len);
err = -ENODEV;
if (!rmac) {
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/ethernet/sun/sunvnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ static int vnet_port_probe(struct vio_dev *vdev, const struct vio_device_id *id)

hp = mdesc_grab();

if (!hp)
return -ENODEV;

vp = vnet_find_parent(hp, vdev->mp, vdev);
if (IS_ERR(vp)) {
pr_err("Cannot find port parent vnet\n");
Expand Down

0 comments on commit 90de546

Please sign in to comment.