Skip to content

Commit 7df7563

Browse files
Uwe Kleine-Königherbertx
authored andcommitted
crypto: atmel-ecc - Remove duplicated error reporting in .remove()
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 <[email protected]> Reviewed-by: Tudor Ambarus <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 6cb3f9b commit 7df7563

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/crypto/atmel-ecc.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,16 @@ static int atmel_ecc_remove(struct i2c_client *client)
349349

350350
/* Return EBUSY if i2c client already allocated. */
351351
if (atomic_read(&i2c_priv->tfm_count)) {
352-
dev_err(&client->dev, "Device is busy\n");
353-
return -EBUSY;
352+
/*
353+
* After we return here, the memory backing the device is freed.
354+
* That happens no matter what the return value of this function
355+
* is because in the Linux device model there is no error
356+
* handling for unbinding a driver.
357+
* If there is still some action pending, it probably involves
358+
* accessing the freed memory.
359+
*/
360+
dev_emerg(&client->dev, "Device is busy, expect memory corruption.\n");
361+
return 0;
354362
}
355363

356364
crypto_unregister_kpp(&atmel_ecdh_nist_p256);

0 commit comments

Comments
 (0)