mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@corigine.com>
To: Sean Anderson <seanga2@gmail.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Rolf Eike Beer <eike-kernel@sf-tec.de>,
	kernel test robot <lkp@intel.com>,
	Dan Carpenter <error27@gmail.com>
Subject: Re: [PATCH net] net: sunhme: Return an error when we are out of slots
Date: Wed, 22 Feb 2023 21:59:33 +0100	[thread overview]
Message-ID: <Y/aCNSlx2p62iDYk@corigine.com> (raw)
In-Reply-To: <20230222170935.1820939-1-seanga2@gmail.com>

On Wed, Feb 22, 2023 at 12:09:35PM -0500, Sean Anderson wrote:
> We only allocate enough space for four devices when the parent is a QFE. If
> we couldn't find a spot (because five devices were created for whatever
> reason), we would not return an error from probe(). Return ENODEV, which
> was what we did before.
> 
> Fixes: 96c6e9faecf1 ("sunhme: forward the error code from pci_enable_device()")

I think the hash for that commit is acb3f35f920b.

However, I also think this problem was introduced by the first hunk of
5b3dc6dda6b1 ("sunhme: Regularize probe errors").

Which is:

--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -2945,7 +2945,6 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 	if (err)
 		goto err_out;
 	pci_set_master(pdev);
-	err = -ENODEV;
 
 	if (!strcmp(prom_name, "SUNW,qfe") || !strcmp(prom_name, "qfe")) {
 		qp = quattro_pci_find(pdev);


Which leads me to wonder if simpler fixes would be either:

1) Reverting the hunk above
2) Or, more in keeping with the rest of that patch,
   explicitly setting err before branching to err_out,
   as you your patch does, but without other logic changes.

   Something like this (*compile tested only!*:

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index 1c16548415cd..2409e7d6c29e 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -2863,8 +2863,10 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
 			if (!qp->happy_meals[qfe_slot])
 				break;
 
-		if (qfe_slot == 4)
+		if (qfe_slot == 4) {
+			err = -ENOMEM;
 			goto err_out;
+		}
 	}
 
 	dev = devm_alloc_etherdev(&pdev->dev, sizeof(struct happy_meal));

Also, I am curious why happy_meal_pci_probe() doesn't just return instaed
of branching to err_out. As err_out only returns err.  I guess there is a
reason for it. But simply returning would probably simplify error handling.
(I'm not suggesting that approach for this fix.)

> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <error27@gmail.com>
> Signed-off-by: Sean Anderson <seanga2@gmail.com>
> ---
> 
>  drivers/net/ethernet/sun/sunhme.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
> index 1c16548415cd..523e26653ec8 100644
> --- a/drivers/net/ethernet/sun/sunhme.c
> +++ b/drivers/net/ethernet/sun/sunhme.c
> @@ -2861,12 +2861,13 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
>  
>  		for (qfe_slot = 0; qfe_slot < 4; qfe_slot++)
>  			if (!qp->happy_meals[qfe_slot])
> -				break;
> +				goto found_slot;
>  
> -		if (qfe_slot == 4)
> -			goto err_out;
> +		err = -ENODEV;
> +		goto err_out;
>  	}
>  
> +found_slot:
>  	dev = devm_alloc_etherdev(&pdev->dev, sizeof(struct happy_meal));
>  	if (!dev) {
>  		err = -ENOMEM;
> -- 
> 2.37.1
> 

  reply	other threads:[~2023-02-22 21:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22 17:09 Sean Anderson
2023-02-22 20:59 ` Simon Horman [this message]
2023-02-22 21:07   ` Sean Anderson
2023-02-22 21:19     ` Simon Horman

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=Y/aCNSlx2p62iDYk@corigine.com \
    --to=simon.horman@corigine.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eike-kernel@sf-tec.de \
    --cc=error27@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=seanga2@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®