[PATCH] spi: amlogic-spisg: drop misleading NULL check on exdesc
Xianwei Zhao
xianwei.zhao at amlogic.com
Wed May 6 19:43:17 PDT 2026
Hi Stepan,
On 2026/5/7 02:35, Stepan Ionichev wrote:
> aml_spisg_setup_transfer() takes a non-NULL exdesc pointer; the
> function dereferences exdesc unconditionally later in the body to
> populate the SPI scatter-gather descriptors (tx_ccsg / rx_ccsg).
> The sole caller, aml_spisg_transfer_one_message(), always passes a
> valid pointer derived from kcalloc().
>
> The "if (exdesc)" guard around the memset() at the start of the
> function is therefore dead and misleading -- it suggests callers
> may pass NULL when in fact they may not. smatch flags the
> inconsistency:
>
> drivers/spi/spi-amlogic-spisg.c:314 aml_spisg_setup_transfer()
> error: we previously assumed 'exdesc' could be null (see line 261)
>
> Drop the check; the unconditional memset matches the unconditional
> dereferences elsewhere in the function and removes the inconsistency
> that smatch reports.
>
> No functional change.
>
> Signed-off-by: Stepan Ionichev<sozdayvek at gmail.com>
> ---
> drivers/spi/spi-amlogic-spisg.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-amlogic-spisg.c b/drivers/spi/spi-amlogic-spisg.c
> index 19c5eba41..b2a916496 100644
> --- a/drivers/spi/spi-amlogic-spisg.c
> +++ b/drivers/spi/spi-amlogic-spisg.c
> @@ -258,8 +258,7 @@ static int aml_spisg_setup_transfer(struct spisg_device *spisg,
> int ret;
>
> memset(desc, 0, sizeof(*desc));
> - if (exdesc)
> - memset(exdesc, 0, sizeof(*exdesc));
> + memset(exdesc, 0, sizeof(*exdesc)); > aml_spisg_set_speed(spisg, xfer->speed_hz);
> xfer->effective_speed_hz = spisg->effective_speed_hz;
Reviewed-by: Xianwei Zhao <xianwei.zhao at amlogic.com>
More information about the linux-amlogic
mailing list