Re: [PATCH] crypto: caam - Avoid GCC memset bug warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 28, 2022 at 04:46:39PM +0800, Herbert Xu wrote:
> Certain versions of gcc don't like the memcpy with a NULL dst
> (which only happens with a zero length).  This only happens
> when debugging is enabled so add an if clause to work around
> these warnings.
> 
> A similar warning used to be generated by sparse but that was
> fixed years ago.
> 
> Link: https://lore.kernel.org/lkml/202210290446.qBayTfzl-lkp@xxxxxxxxx
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Reported-by: Kees Cook <keescook@xxxxxxxxxxxx>
> Reported-by: Uwe Kleine-K�nig <u.kleine-koenig@xxxxxxxxxxxxxx>
> Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
> 
> diff --git a/drivers/crypto/caam/desc_constr.h b/drivers/crypto/caam/desc_constr.h
> index 62ce6421bb3f..824c94d44f94 100644
> --- a/drivers/crypto/caam/desc_constr.h
> +++ b/drivers/crypto/caam/desc_constr.h
> @@ -163,7 +163,8 @@ static inline void append_data(u32 * const desc, const void *data, int len)
>  {
>  	u32 *offset = desc_end(desc);
>  
> -	if (len) /* avoid sparse warning: memcpy with byte count of 0 */
> +	/* Avoid gcc warning: memcpy with data == NULL */
> +	if (!IS_ENABLED(CONFIG_CRYPTO_DEV_FSL_CAAM_DEBUG) || data)

I just tried: For me a plain

	if (data)

is also enough to make both gcc and sparse happy.

(On a related note, sparse reports:

  CHECK   drivers/crypto/caam/jr.c
drivers/crypto/caam/jr.c: note: in included file (through arch/arm64/include/asm/io.h, include/linux/io.h, include/linux/irq.h, ...):
include/asm-generic/io.h:290:22: warning: incorrect type in argument 1 (different base types)
include/asm-generic/io.h:290:22:    expected unsigned long long [usertype] val
include/asm-generic/io.h:290:22:    got restricted __le64 [usertype]
include/asm-generic/io.h:290:22: warning: incorrect type in argument 1 (different base types)
include/asm-generic/io.h:290:22:    expected unsigned long long [usertype] val
include/asm-generic/io.h:290:22:    got restricted __le64 [usertype]

Didn't look into that though.)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux