Re: [PATCH] crypto: mpi: add NULL checks to mpi_normalize().

From: Herbert Xu
Date: Fri Aug 09 2024 - 00:29:31 EST


On Wed, Aug 07, 2024 at 02:20:36PM +0000, Roman Smirnov wrote:
>
> Svace found a similar case but it is no longer relevant:
>
> NULL constant:
> mpi_ec_mul_point()
> ec_mulm(z3, point->z, z2, ctx)
> ec_mod()
> mpi_mod()
> mpi_fdiv_r()
> mpi_tdiv_r()
> mpi_tdiv_qr()
> mpi_resize()
> kcalloc()

In general, I think it's better to deal with the error at the
point of allocation. So whoever calls mpi_resize should check
for errors and return an error if appropriate.

We can deal with this if this function is ever reintroduced.

Thanks,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt