All of lore.kernel.org
 help / color / mirror / Atom feed
From: Piotr Raczynski <piotr.raczynski@intel.com>
To: Liang He <windhl@126.com>
Cc: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>, <netdev@vger.kernel.org>
Subject: Re: [PATCH] ethernet: sun: add check for the mdesc_grab()
Date: Wed, 15 Mar 2023 10:15:21 +0100	[thread overview]
Message-ID: <ZBGMqfPQiR84NkMQ@nimitz> (raw)
In-Reply-To: <20230315060021.1741151-1-windhl@126.com>

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>

  reply	other threads:[~2023-03-15  9:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-15  6:00 [PATCH] ethernet: sun: add check for the mdesc_grab() Liang He
2023-03-15  9:15 ` Piotr Raczynski [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZBGMqfPQiR84NkMQ@nimitz \
    --to=piotr.raczynski@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=windhl@126.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.