Netdev List
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Christian Lamparter <chunkeey@gmail.com>
Cc: Kalle Valo <kvalo@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	"John W. Linville" <linville@tuxdriver.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Christian Lamparter <chunkeey@web.de>,
	linux-wireless <linux-wireless@vger.kernel.org>,
	Netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH] p54: Fix an error handling path in p54spi_probe()
Date: Sun, 12 Jun 2022 23:02:50 +0200	[thread overview]
Message-ID: <59fdf712-5825-9c0d-ee28-7b6b485d96bd@wanadoo.fr> (raw)
In-Reply-To: <CAAd0S9CFQn33FsmaSMdVwHd__HW8NXM0MvDzJfNuxTUm6Hh4oQ@mail.gmail.com>

Le 12/06/2022 à 22:45, Christian Lamparter a écrit :
> Hi,
> 
> On Sun, Jun 12, 2022 at 9:55 PM Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:
>>
>> If an error occurs after a successful call to p54spi_request_firmware(), it
>> must be undone by a corresponding release_firmware()
> 
> Yes, good catch. That makes sense.
> 
>> as already done in the error handling path of p54spi_request_firmware() and in
>> the .remove() function.
>>
>> Add the missing call in the error handling path and update some goto
>> label accordingly.
> 
>  From what I know, "release_firmware(some *fw)" includes a check for
> *fw != NULL already.

Correct.

> 
> we could just add a single release_firmware(priv->firmware) to any of the error

Not my favorite style, but if it is preferred this way, NP.

> paths labels (i.e.: err_free_common) and then we remove the extra
> release_firmware(...) in p54spi_request_firmware so that we don't try to free
> it twice.

Sure. I'll add a comment to explain where is is released in case of error.

> 
> (This also skips the need for having "err_release_firmaware" .. which
> unfortunately has a small typo)
> 
> Regards,
> Christian
> 
>> Fixes: cd8d3d321285 ("p54spi: p54spi driver")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>>   drivers/net/wireless/intersil/p54/p54spi.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/wireless/intersil/p54/p54spi.c b/drivers/net/wireless/intersil/p54/p54spi.c
>> index f99b7ba69fc3..679ac164c994 100644
>> --- a/drivers/net/wireless/intersil/p54/p54spi.c
>> +++ b/drivers/net/wireless/intersil/p54/p54spi.c
>> @@ -650,14 +650,16 @@ static int p54spi_probe(struct spi_device *spi)
>>
>>          ret = p54spi_request_eeprom(hw);
>>          if (ret)
>> -               goto err_free_common;
>> +               goto err_release_firmaware;
>>
>>          ret = p54_register_common(hw, &priv->spi->dev);
>>          if (ret)
>> -               goto err_free_common;
>> +               goto err_release_firmaware;
>>
>>          return 0;
>>
>> +err_release_firmaware:
>> +       release_firmware(priv->firmware);
>>   err_free_common:
>>          free_irq(gpio_to_irq(p54spi_gpio_irq), spi);
>>   err_free_gpio_irq:
>> --
>> 2.34.1
>>
> 


      reply	other threads:[~2022-06-12 21:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-12 19:54 [PATCH] p54: Fix an error handling path in p54spi_probe() Christophe JAILLET
2022-06-12 20:45 ` Larry Finger
2022-06-12 20:45 ` Christian Lamparter
2022-06-12 21:02   ` Christophe JAILLET [this message]

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=59fdf712-5825-9c0d-ee28-7b6b485d96bd@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=chunkeey@gmail.com \
    --cc=chunkeey@web.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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