linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: <Tudor.Ambarus@microchip.com>
To: <u.kleine-koenig@pengutronix.de>
Cc: alexandre.belloni@bootlin.com, linux-crypto@vger.kernel.org,
	kernel@pengutronix.de, Claudiu.Beznea@microchip.com,
	linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org
Subject: Re: [PATCH] crypto: atmel-ecc - Remove duplicated error reporting in .remove()
Date: Wed, 8 Jun 2022 04:33:48 +0000	[thread overview]
Message-ID: <fd8d1ca1-b6fa-ecb9-ba71-80449af59a9a@microchip.com> (raw)
In-Reply-To: <20220520172100.773730-1-u.kleine-koenig@pengutronix.de>

On 5/20/22 20:21, Uwe Kleine-König wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> Returning an error value in an i2c remove callback results in an error
> message being emitted by the i2c core, but otherwise it doesn't make a
> difference. The device goes away anyhow and the devm cleanups are
> called.
> 
> As atmel_ecc_remove() already emits an error message on failure and the
> additional error message by the i2c core doesn't add any useful
> information, change the return value to zero to suppress this message.
> 
> Also make the error message a bit more drastical because when the device
> is still busy on remove, it's likely that it will access freed memory
> soon.
> 
> This patch is a preparation for making i2c remove callbacks return void.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>

> ---
>  drivers/crypto/atmel-ecc.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
> index 333fbefbbccb..6ba38275de8c 100644
> --- a/drivers/crypto/atmel-ecc.c
> +++ b/drivers/crypto/atmel-ecc.c
> @@ -349,8 +349,16 @@ static int atmel_ecc_remove(struct i2c_client *client)
> 
>         /* Return EBUSY if i2c client already allocated. */
>         if (atomic_read(&i2c_priv->tfm_count)) {
> -               dev_err(&client->dev, "Device is busy\n");
> -               return -EBUSY;
> +               /*
> +                * After we return here, the memory backing the device is freed.
> +                * That happens no matter what the return value of this function
> +                * is because in the Linux device model there is no error
> +                * handling for unbinding a driver.
> +                * If there is still some action pending, it probably involves
> +                * accessing the freed memory.
> +                */
> +               dev_emerg(&client->dev, "Device is busy, expect memory corruption.\n");
> +               return 0;
>         }
> 
>         crypto_unregister_kpp(&atmel_ecdh_nist_p256);
> 
> base-commit: 3123109284176b1532874591f7c81f3837bbdc17
> --
> 2.35.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-06-08  4:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-13 13:59 Bug in atmel-ecc driver Uwe Kleine-König
2022-05-17 10:24 ` Uwe Kleine-König
2022-05-17 13:11   ` Tudor.Ambarus
2022-05-17 14:33     ` Uwe Kleine-König
2022-05-18 10:07       ` Tudor.Ambarus
2022-05-18 21:36         ` Uwe Kleine-König
2022-05-20 17:21         ` [PATCH] crypto: atmel-ecc - Remove duplicated error reporting in .remove() Uwe Kleine-König
2022-06-07  6:48           ` Uwe Kleine-König
2022-06-08  4:33           ` Tudor.Ambarus [this message]
2022-06-08  7:04             ` Uwe Kleine-König
2022-06-08  8:35               ` Tudor.Ambarus
2022-06-10  9:14           ` Herbert Xu

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=fd8d1ca1-b6fa-ecb9-ba71-80449af59a9a@microchip.com \
    --to=tudor.ambarus@microchip.com \
    --cc=Claudiu.Beznea@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).