mbox series

[0/2] crypto: CMake crypto_engine_exit() return void

Message ID 20230923100806.1762943-1-u.kleine-koenig@pengutronix.de (mailing list archive)
Headers show
Series crypto: CMake crypto_engine_exit() return void | expand

Message

Uwe Kleine-König Sept. 23, 2023, 10:08 a.m. UTC
Hello,

all but one crypto driver ignore the return code of
crypto_engine_exit(). This is ok as this function is called in
situations (remove callback, or error path of probe) where errors cannot
be handled anyhow. This series adapts the only driver that doesn't
ignore the error code (and removes the bogous try to handle it) and then
changes crypto_engine_exit() to return void to prevent similar silly
tries in the future.

Note however there is still something to fix: If crypto_engine_stop()
fails in crypto_engine_exit() the kworker stays around but *engine will
be freed. So if something triggers the worker afterwards, this results
in an oops (or memory corruption if the freed memory is reused already).
This needs adaptions in the core, specific device drivers are unaffected
by this, so changing crypto_engine_exit() to return void is a step in
the right direction for this fix, too.

Best regards
Uwe

Uwe Kleine-König (2):
  crypto: keembay - Don't pass errors to the caller in .remove()
  crypto: Make crypto_engine_exit() return void

 crypto/crypto_engine.c                              |  8 ++------
 drivers/crypto/intel/keembay/keembay-ocs-hcu-core.c | 11 +++--------
 include/crypto/engine.h                             |  2 +-
 3 files changed, 6 insertions(+), 15 deletions(-)

base-commit: 940fcc189c51032dd0282cbee4497542c982ac59

Comments

Herbert Xu Oct. 1, 2023, 8:35 a.m. UTC | #1
On Sat, Sep 23, 2023 at 12:08:04PM +0200, Uwe Kleine-König wrote:
> Hello,
> 
> all but one crypto driver ignore the return code of
> crypto_engine_exit(). This is ok as this function is called in
> situations (remove callback, or error path of probe) where errors cannot
> be handled anyhow. This series adapts the only driver that doesn't
> ignore the error code (and removes the bogous try to handle it) and then
> changes crypto_engine_exit() to return void to prevent similar silly
> tries in the future.
> 
> Note however there is still something to fix: If crypto_engine_stop()
> fails in crypto_engine_exit() the kworker stays around but *engine will
> be freed. So if something triggers the worker afterwards, this results
> in an oops (or memory corruption if the freed memory is reused already).
> This needs adaptions in the core, specific device drivers are unaffected
> by this, so changing crypto_engine_exit() to return void is a step in
> the right direction for this fix, too.
> 
> Best regards
> Uwe
> 
> Uwe Kleine-König (2):
>   crypto: keembay - Don't pass errors to the caller in .remove()
>   crypto: Make crypto_engine_exit() return void
> 
>  crypto/crypto_engine.c                              |  8 ++------
>  drivers/crypto/intel/keembay/keembay-ocs-hcu-core.c | 11 +++--------
>  include/crypto/engine.h                             |  2 +-
>  3 files changed, 6 insertions(+), 15 deletions(-)
> 
> base-commit: 940fcc189c51032dd0282cbee4497542c982ac59
> -- 
> 2.40.1

All applied.  Thanks.