ethernet: sun: add check for the mdesc_grab()
Subsystems (2)
PATCH 1/1 ethernet: sun: add check for the mdesc_grab()
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.
--- drivers/net/ethernet/sun/ldmvsw.c | 3 +++ drivers/net/ethernet/sun/sunvnet.c | 3 +++ 2 files changed, 6 insertions(+)
drivers/net/ethernet/sun/ldmvsw.c +3 -0
@@ -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) {
drivers/net/ethernet/sun/sunvnet.c +3 -0
@@ -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" );
Signature · 1 line
2.25.1
Quoted 43 lines · Liang He
In
vnet_port_probe()andvsw_port_probe(), we should check the return value ofmdesc_grab()as it may return NULL which can caused NPD bugs.Fixes 5d01fa0c6bd8 ("ldmvsw: Add ldmvsw.c driver code")Fixes 43fdf27470b2 ("[SPARC64]: Abstract out mdesc accesses for better MD update handling.")Signed-off-by Liang He <[email protected]>--- drivers/net/ethernet/sun/ldmvsw.c | 3 +++ drivers/net/ethernet/sun/sunvnet.c | 3 +++ 2 files changed, 6 insertions(+)drivers/net/ethernet/sun/ldmvsw.c +3
-0@@ -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) {drivers/net/ethernet/sun/sunvnet.c +3
-0@@ -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" );Signature · 1 line
2.25.1
Perfectly valid checks, thanks.
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 9 lines · On Wed, 15 Mar 2023 14:00:21 +0800 you wrote:
In
vnet_port_probe()andvsw_port_probe(), we should check the return value ofmdesc_grab()as it may return NULL which can caused NPD bugs.Fixes 5d01fa0c6bd8 ("ldmvsw: Add ldmvsw.c driver code")Fixes 43fdf27470b2 ("[SPARC64]: Abstract out mdesc accesses for better MD update handling.")Signed-off-by Liang He <[email protected]>[...]
Here is the summary with links:
- ethernet: sun: add check for the mdesc_grab()
https://git.kernel.org/netdev/net/c/90de546d9a0b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Jakub Kicinski
maintainerdrivers/net/ethernet/sun/ldmvsw.c static int vsw_port_probe(struct vio_dev *vdev, const struct vio_device_id *id) · line 291
Quoted 4 lines · On Wed, 15 Mar 2023 14:00:21 +0800 Liang He wrote:
drivers/net/ethernet/sun/ldmvsw.c +2
-0hp =mdesc_grab (); +if (!hp) +return -ENODEV ;
no empty line between the function call and error check, please
Quoted 7 lines · Jakub Kicinski
drivers/net/ethernet/sun/ldmvsw.c static int vsw_port_probe(struct vio_dev *vdev, const struct vio_device_id *id) · line 291
Quoted 4 lines · On Wed, 15 Mar 2023 14:00:21 +0800 Liang He wrote:
drivers/net/ethernet/sun/ldmvsw.c +2
-0hp =mdesc_grab (); +if (!hp) +return -ENODEV ;no empty line between the function call and error check, please
Hi, Jakub,
Thanks very much for your review and reply.
While I have already prepared the new version patch, my last patch has been Reviewed-by Piotr Raczynski and applied to netdev/net.git by David S.Miller.
So should I send the new patch again?
Thanks,
Liang
Jakub Kicinski
maintainerQuoted 9 lines · On Sun, 19 Mar 2023 19:30:30 +0800 (CST) Liang He wrote:
Quoted 7 lines · Jakub Kicinski
drivers/net/ethernet/sun/ldmvsw.c static int vsw_port_probe(struct vio_dev *vdev, const struct vio_device_id *id) · line 291
Quoted 4 lines · On Wed, 15 Mar 2023 14:00:21 +0800 Liang He wrote:
drivers/net/ethernet/sun/ldmvsw.c +2
-0hp =mdesc_grab (); +if (!hp) +return -ENODEV ;no empty line between the function call and error check, please
Quoted 7 lines
Hi, Jakub,
Thanks very much for your review and reply.
While I have already prepared the new version patch, my last patch has been Reviewed-by Piotr Raczynski and applied to netdev/net.git by David S.Miller.
You're right, I missed that.
Quoted 1 line
So should I send the new patch again?
No need, we can't replace it now so let's leave it be.