staging: most: dim2: remove unnecessary NULL check in try_start_dim_transfer()
Subsystems (2)
PATCH 1/1 staging: most: dim2: remove unnecessary NULL check in try_start_dim_transfer()
From: Gabriel Rondon <[email protected]>
Remove the !hdm_ch check. Although hdm_ch is a function parameter, it is already dereferenced on the preceding line to initialize head (head = &hdm_ch->pending_list), so a NULL check after that point is dead code.
--- drivers/staging/most/dim2/dim2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/most/dim2/dim2.c +1 -1
@@ -165,7 +165,7 @@ static int try_start_dim_transfer(struct hdm_channel *hdm_ch)unsigned long flags;struct dim_ch_state st; -if (!hdm_ch || !hdm_ch->is_initialized) +if (!hdm_ch->is_initialized)return -EINVAL ;spin_lock_irqsave (&dim_lock, flags);
Signature · 1 line
2.33.0
Hi Gabriel,
Thanks for your patch, which is now commit fde67f5b1fc77f3c ("staging:
most: dim2: remove unnecessary NULL check in try_start_dim_transfer()") in staging/staging-next.
Quoted 5 lines · On Wed, 1 Apr 2026 at 12:11, <[email protected]> wrote:
From: Gabriel Rondon <[email protected]>
Remove the !hdm_ch check. Although
hdm_chis a function parameter, it is already dereferenced on the preceding line to initialize head (head =&hdm_ch->pending_list), so a NULL check after that
FTR, this is not a pointer dereference, but merely pointer arithmetic, due to the "&".
Quoted 9 lines
point is dead code.
Reported-by Dan Carpenter <[email protected]>Signed-off-by Gabriel Rondon <[email protected]>
drivers/staging/most/dim2/dim2.c static int try_start_dim_transfer(struct hdm_channel *hdm_ch) · line 171
Quoted 8 lines
drivers/staging/most/dim2/dim2.c +1
-1@@ -165,7 +165,7 @@ static int try_start_dim_transfer(struct hdm_channel *hdm_ch)unsigned long flags;struct dim_ch_state st; -if (!hdm_ch || !hdm_ch->is_initialized) +if (!hdm_ch->is_initialized)return -EINVAL ;spin_lock_irqsave (&dim_lock, flags);
The passed hdm_ch can indeed not be NULL, according to the same rationale as your commit 6aa2b11ce527c23e ("staging: most: dim2: remove unnecessary NULL check in service_done_flag()") in staging/staging-next.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds