public inbox for linux-kernel@vger.kernel.org
 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,
	kernel test robot <lkp@intel.com>,
	Dan Carpenter <error27@gmail.com>
Subject: Re: [PATCH net-next v4 01/10] net: sunhme: Fix uninitialized return code
Date: Sat, 25 Mar 2023 09:26:31 +0100	[thread overview]
Message-ID: <ZB6wNwHr3hViHC2O@corigine.com> (raw)
In-Reply-To: <ZB6t/64NoGejdxUG@corigine.com>

On Sat, Mar 25, 2023 at 09:17:03AM +0100, Simon Horman wrote:
> Hi Sean,
> 
> On Fri, Mar 24, 2023 at 01:51:27PM -0400, Sean Anderson wrote:
> > Fix an uninitialized return code if we never found a qfe slot. It would be
> > a bug if we ever got into this situation, but it's good to return something
> > tracable.
> > 
> > Fixes: acb3f35f920b ("sunhme: forward the error code from pci_enable_device()")
> 
> I think it might be,
> 
> Fixes: 5b3dc6dda6b1 ("sunhme: Regularize probe errors")
> 
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <error27@gmail.com>
> 
> Checkpatch requests a Link tag after Reported-by tags.
> 
> Link: https://lore.kernel.org/oe-kbuild/20230222135715.hjXBN9H5dr7nCnI_Ye2s5H--HsnWom4o9AMScThhDRM@z/T/
> 
> > Signed-off-by: Sean Anderson <seanga2@gmail.com>
> > ---
> > 
> > Changes in v4:
> > - Move this fix to its own commit
> > 
> >  drivers/net/ethernet/sun/sunhme.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
> > index b0c7ab74a82e..7cf8210ebbec 100644
> > --- a/drivers/net/ethernet/sun/sunhme.c
> > +++ b/drivers/net/ethernet/sun/sunhme.c
> > @@ -2834,7 +2834,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
> >  	int i, qfe_slot = -1;
> >  	char prom_name[64];
> >  	u8 addr[ETH_ALEN];
> > -	int err;
> > +	int err = -ENODEV;
> >  
> >  	/* Now make sure pci_dev cookie is there. */
> >  #ifdef CONFIG_SPARC
> 
> Unfortunately I don't think this is the right fix,
> and indeed smatch still complains with it applied.
> 
> The reason is that a few lines further down there is:
> 
>         err = pcim_enable_device(pdev);
>         if (err)
>                 goto err_out;
> 
> Which overrides the initialisation of err.
> Before getting to the line that smatch highlights, correctly as far
> as I can tell, as having a missing error code.
> 
> 			if (qfe_slot == 4)
> 				goto err_out;
> 
> As err_out simply calls 'return err' one could just return here.
> And perhaps that is a nice cleanup to roll out at some point.

I see that point is patch 9/10, which also fixes the bug
reported by smatch :)

> But to be in keeping with the style of the function, as a minimal fix,
> I think the following might be appropriate.
> 
> Note, with this applied err doesn't need to be initialised at the top of
> the function (as far as my invocation of smatch is concerned).
> 
> diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
> index b0c7ab74a82e..d6df778a0052 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 = -ENODEV;
>  			goto err_out;
> +		}
>  	}
>  
>  	dev = devm_alloc_etherdev(&pdev->dev, sizeof(struct happy_meal));
> 

  reply	other threads:[~2023-03-25  8:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24 17:51 [PATCH net-next v4 00/10] net: sunhme: Probe/IRQ cleanups Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 01/10] net: sunhme: Fix uninitialized return code Sean Anderson
2023-03-25  8:17   ` Simon Horman
2023-03-25  8:26     ` Simon Horman [this message]
2023-03-24 17:51 ` [PATCH net-next v4 02/10] net: sunhme: Just restart autonegotiation if we can't bring the link up Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 03/10] net: sunhme: Remove residual polling code Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 04/10] net: sunhme: Unify IRQ requesting Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 05/10] net: sunhme: Alphabetize includes Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 06/10] net: sunhme: Switch SBUS to devres Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 07/10] net: sunhme: Consolidate mac address initialization Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 08/10] net: sunhme: Clean up mac address init Sean Anderson
2023-03-24 17:51 ` [PATCH net-next v4 09/10] net: sunhme: Inline error returns Sean Anderson
2023-03-25  8:24   ` Simon Horman
2023-03-25  8:29   ` Simon Horman
2023-03-24 17:51 ` [PATCH net-next v4 10/10] net: sunhme: Consolidate common probe tasks Sean Anderson
2023-03-25  9:10   ` Simon Horman
2023-03-25 16:06     ` Sean Anderson
2023-03-26  7:57       ` Simon Horman
2023-03-27  7:50 ` [PATCH net-next v4 00/10] net: sunhme: Probe/IRQ cleanups patchwork-bot+netdevbpf

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=ZB6wNwHr3hViHC2O@corigine.com \
    --to=simon.horman@corigine.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --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