All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ethernet: sun: add check for the mdesc_grab()
@ 2023-03-15  6:00 Liang He
  2023-03-15  9:15 ` Piotr Raczynski
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Liang He @ 2023-03-15  6:00 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, netdev, windhl

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.")
Signed-off-by: Liang He <windhl@126.com>
---
 drivers/net/ethernet/sun/ldmvsw.c  | 3 +++
 drivers/net/ethernet/sun/sunvnet.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/sun/ldmvsw.c b/drivers/net/ethernet/sun/ldmvsw.c
index 8addee6d04bd..734a817d3c94 100644
--- a/drivers/net/ethernet/sun/ldmvsw.c
+++ b/drivers/net/ethernet/sun/ldmvsw.c
@@ -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) {
diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c
index fe86fbd58586..e220620d0ffc 100644
--- a/drivers/net/ethernet/sun/sunvnet.c
+++ b/drivers/net/ethernet/sun/sunvnet.c
@@ -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");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] ethernet: sun: add check for the mdesc_grab()
  2023-03-15  6:00 [PATCH] ethernet: sun: add check for the mdesc_grab() Liang He
@ 2023-03-15  9:15 ` Piotr Raczynski
  2023-03-17  7:50 ` patchwork-bot+netdevbpf
  2023-03-18  5:29 ` Jakub Kicinski
  2 siblings, 0 replies; 6+ messages in thread
From: Piotr Raczynski @ 2023-03-15  9:15 UTC (permalink / raw)
  To: Liang He; +Cc: davem, edumazet, kuba, pabeni, netdev

On Wed, Mar 15, 2023 at 02:00:21PM +0800, Liang He 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.")
> Signed-off-by: Liang He <windhl@126.com>
> ---
>  drivers/net/ethernet/sun/ldmvsw.c  | 3 +++
>  drivers/net/ethernet/sun/sunvnet.c | 3 +++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/drivers/net/ethernet/sun/ldmvsw.c b/drivers/net/ethernet/sun/ldmvsw.c
> index 8addee6d04bd..734a817d3c94 100644
> --- a/drivers/net/ethernet/sun/ldmvsw.c
> +++ b/drivers/net/ethernet/sun/ldmvsw.c
> @@ -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) {
> diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c
> index fe86fbd58586..e220620d0ffc 100644
> --- a/drivers/net/ethernet/sun/sunvnet.c
> +++ b/drivers/net/ethernet/sun/sunvnet.c
> @@ -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");
> -- 
> 2.25.1
> 
Perfectly valid checks, thanks.
Reviewed-by: Piotr Raczynski <piotr.raczynski@intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ethernet: sun: add check for the mdesc_grab()
  2023-03-15  6:00 [PATCH] ethernet: sun: add check for the mdesc_grab() Liang He
  2023-03-15  9:15 ` Piotr Raczynski
@ 2023-03-17  7:50 ` patchwork-bot+netdevbpf
  2023-03-18  5:29 ` Jakub Kicinski
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-03-17  7:50 UTC (permalink / raw)
  To: Liang He; +Cc: davem, edumazet, kuba, pabeni, netdev

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

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.")
> Signed-off-by: Liang He <windhl@126.com>
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ethernet: sun: add check for the mdesc_grab()
  2023-03-15  6:00 [PATCH] ethernet: sun: add check for the mdesc_grab() Liang He
  2023-03-15  9:15 ` Piotr Raczynski
  2023-03-17  7:50 ` patchwork-bot+netdevbpf
@ 2023-03-18  5:29 ` Jakub Kicinski
  2023-03-19 11:30   ` Liang He
  2 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2023-03-18  5:29 UTC (permalink / raw)
  To: Liang He; +Cc: davem, edumazet, pabeni, netdev

On Wed, 15 Mar 2023 14:00:21 +0800 Liang He wrote:
>  	hp = mdesc_grab();
>  
> +	if (!hp)
> +		return -ENODEV;

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re:Re: [PATCH] ethernet: sun: add check for the mdesc_grab()
  2023-03-18  5:29 ` Jakub Kicinski
@ 2023-03-19 11:30   ` Liang He
  2023-03-19 18:39     ` Jakub Kicinski
  0 siblings, 1 reply; 6+ messages in thread
From: Liang He @ 2023-03-19 11:30 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, edumazet, pabeni, netdev


At 2023-03-18 13:29:44, "Jakub Kicinski" <kuba@kernel.org> wrote:
>On Wed, 15 Mar 2023 14:00:21 +0800 Liang He wrote:
>>  	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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ethernet: sun: add check for the mdesc_grab()
  2023-03-19 11:30   ` Liang He
@ 2023-03-19 18:39     ` Jakub Kicinski
  0 siblings, 0 replies; 6+ messages in thread
From: Jakub Kicinski @ 2023-03-19 18:39 UTC (permalink / raw)
  To: Liang He; +Cc: davem, edumazet, pabeni, netdev

On Sun, 19 Mar 2023 19:30:30 +0800 (CST) Liang He wrote:
> At 2023-03-18 13:29:44, "Jakub Kicinski" <kuba@kernel.org> wrote:
> >On Wed, 15 Mar 2023 14:00:21 +0800 Liang He wrote:  
> >>  	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.

You're right, I missed that.

> So should I send the new patch again? 

No need, we can't replace it now so let's leave it be.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-19 18:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15  6:00 [PATCH] ethernet: sun: add check for the mdesc_grab() Liang He
2023-03-15  9:15 ` Piotr Raczynski
2023-03-17  7:50 ` patchwork-bot+netdevbpf
2023-03-18  5:29 ` Jakub Kicinski
2023-03-19 11:30   ` Liang He
2023-03-19 18:39     ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.