Skip to contentSkip to conversation

ethernet: sun: add check for the mdesc_grab()

PATCH Applied Liang He 4 participants 6 messages Mar 15, 2023 – Mar 19, 2023

Subsystems (2)
lore
Share & tools
lore

Liang He

author
#0 lore raw

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.

Fixes 5d01fa0c6bd8 ("ldmvsw: Add ldmvsw.c driver code")
Fixes 43fdf27470b2 ("[SPARC64]: Abstract out mdesc accesses for better MD update handling.")
---
 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
index 8addee6d04bd..734a817d3c94 100644
@@ -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
index fe86fbd58586..e220620d0ffc 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 43 lines · Liang He

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 5d01fa0c6bd8 ("ldmvsw: Add ldmvsw.c driver code")
Fixes 43fdf27470b2 ("[SPARC64]: Abstract out mdesc accesses for better MD update handling.")
---
 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
index 8addee6d04bd..734a817d3c94 100644
@@ -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
index fe86fbd58586..e220620d0ffc 100644
@@ -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.

#2 lore raw
In reply to Liang He
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() and vsw_port_probe(), we should check the return value of mdesc_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.")

[...]

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
maintainer
#3 lore raw
In reply to Liang He

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 -0
 	hp = mdesc_grab();
 
+	if (!hp)
+		return -ENODEV;

no empty line between the function call and error check, please

author
#4 lore raw
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 -0
 	hp = 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

maintainer
#5 lore raw
Quoted 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 -0
 	hp = 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.