Linux SPI subsystem development
 help / color / mirror / Atom feed
* [PATCH] spi: amlogic-spisg: drop misleading NULL check on exdesc
@ 2026-05-06 18:35 Stepan Ionichev
  2026-05-07  2:43 ` Xianwei Zhao
  2026-05-07  8:25 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Stepan Ionichev @ 2026-05-06 18:35 UTC (permalink / raw)
  To: sunny.luo
  Cc: xianwei.zhao, broonie, linux-amlogic, linux-spi, linux-kernel,
	Stepan Ionichev

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>
---
 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;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] spi: amlogic-spisg: drop misleading NULL check on exdesc
  2026-05-06 18:35 [PATCH] spi: amlogic-spisg: drop misleading NULL check on exdesc Stepan Ionichev
@ 2026-05-07  2:43 ` Xianwei Zhao
  2026-05-07  8:25 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Xianwei Zhao @ 2026-05-07  2:43 UTC (permalink / raw)
  To: Stepan Ionichev, sunny.luo
  Cc: broonie, linux-amlogic, linux-spi, linux-kernel

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@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@amlogic.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] spi: amlogic-spisg: drop misleading NULL check on exdesc
  2026-05-06 18:35 [PATCH] spi: amlogic-spisg: drop misleading NULL check on exdesc Stepan Ionichev
  2026-05-07  2:43 ` Xianwei Zhao
@ 2026-05-07  8:25 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-05-07  8:25 UTC (permalink / raw)
  To: sunny.luo, Stepan Ionichev
  Cc: xianwei.zhao, linux-amlogic, linux-spi, linux-kernel

On Wed, 06 May 2026 23:35:12 +0500, Stepan Ionichev wrote:
> spi: amlogic-spisg: drop misleading NULL check on exdesc

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.2

Thanks!

[1/1] spi: amlogic-spisg: drop misleading NULL check on exdesc
      https://git.kernel.org/broonie/spi/c/54725e3049e1

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-07 14:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-06 18:35 [PATCH] spi: amlogic-spisg: drop misleading NULL check on exdesc Stepan Ionichev
2026-05-07  2:43 ` Xianwei Zhao
2026-05-07  8:25 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox