]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
spi: amlogic-spisg: drop misleading NULL check on exdesc
authorStepan Ionichev <sozdayvek@gmail.com>
Wed, 6 May 2026 18:35:12 +0000 (23:35 +0500)
committerMark Brown <broonie@kernel.org>
Thu, 7 May 2026 08:25:51 +0000 (17:25 +0900)
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@gmail.com>
Reviewed-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
Link: https://patch.msgid.link/20260506183513.482-1-sozdayvek@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-amlogic-spisg.c

index f9de2d2c92132b238c22bafc8a25dc88e2815ea7..601fb73b35954c7d317d72a495b4096164f71a54 100644 (file)
@@ -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;