public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] staging: vme_user: reorder NULL check after kzalloc in fake_crcsr_init
@ 2026-02-07 21:55 Artem Lytkin
  2026-02-08  2:33 ` Ethan Tidmore
  2026-02-08  6:35 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 3+ messages in thread
From: Artem Lytkin @ 2026-02-07 21:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, linux-kernel, Artem Lytkin

Move the NULL check for bridge->crcsr_kernel before its use in
fake_ptr_to_pci(). While fake_ptr_to_pci() is a simple cast that
handles NULL safely, using a value before validating it is a bad
pattern that static analyzers flag and could become a real issue
if fake_ptr_to_pci() changes in the future.

Signed-off-by: Artem Lytkin <iprintercanon@gmail.com>
---
 drivers/staging/vme_user/vme_fake.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vme_user/vme_fake.c b/drivers/staging/vme_user/vme_fake.c
index 731fbba17..506bc5439 100644
--- a/drivers/staging/vme_user/vme_fake.c
+++ b/drivers/staging/vme_user/vme_fake.c
@@ -1029,9 +1029,9 @@ static int fake_crcsr_init(struct vme_bridge *fake_bridge)
 
 	/* Allocate mem for CR/CSR image */
 	bridge->crcsr_kernel = kzalloc(VME_CRCSR_BUF_SIZE, GFP_KERNEL);
-	bridge->crcsr_bus = fake_ptr_to_pci(bridge->crcsr_kernel);
 	if (!bridge->crcsr_kernel)
 		return -ENOMEM;
+	bridge->crcsr_bus = fake_ptr_to_pci(bridge->crcsr_kernel);
 
 	vstat = fake_slot_get(fake_bridge);
 
-- 
2.43.0


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

* Re: [PATCH] staging: vme_user: reorder NULL check after kzalloc in fake_crcsr_init
  2026-02-07 21:55 [PATCH] staging: vme_user: reorder NULL check after kzalloc in fake_crcsr_init Artem Lytkin
@ 2026-02-08  2:33 ` Ethan Tidmore
  2026-02-08  6:35 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 3+ messages in thread
From: Ethan Tidmore @ 2026-02-08  2:33 UTC (permalink / raw)
  To: Artem Lytkin, Greg Kroah-Hartman; +Cc: linux-staging, linux-kernel

On Sat Feb 7, 2026 at 3:55 PM CST, Artem Lytkin wrote:
> Move the NULL check for bridge->crcsr_kernel before its use in
> fake_ptr_to_pci(). While fake_ptr_to_pci() is a simple cast that
> handles NULL safely, using a value before validating it is a bad
> pattern that static analyzers flag and could become a real issue
> if fake_ptr_to_pci() changes in the future.
>
> Signed-off-by: Artem Lytkin <iprintercanon@gmail.com>

LGTM.

Next time, in your subject line, it's standard practice to end function
names with () to make it clear you're talking about a function.

Reviewed-by: Ethan Tidmore <ethantidmore06@gmail.com>

Thanks,

ET

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

* Re: [PATCH] staging: vme_user: reorder NULL check after kzalloc in fake_crcsr_init
  2026-02-07 21:55 [PATCH] staging: vme_user: reorder NULL check after kzalloc in fake_crcsr_init Artem Lytkin
  2026-02-08  2:33 ` Ethan Tidmore
@ 2026-02-08  6:35 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2026-02-08  6:35 UTC (permalink / raw)
  To: Artem Lytkin; +Cc: linux-staging, linux-kernel

On Sat, Feb 07, 2026 at 09:55:02PM +0000, Artem Lytkin wrote:
> Move the NULL check for bridge->crcsr_kernel before its use in
> fake_ptr_to_pci(). While fake_ptr_to_pci() is a simple cast that
> handles NULL safely, using a value before validating it is a bad
> pattern that static analyzers flag and could become a real issue
> if fake_ptr_to_pci() changes in the future.
> 
> Signed-off-by: Artem Lytkin <iprintercanon@gmail.com>
> ---
>  drivers/staging/vme_user/vme_fake.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/vme_user/vme_fake.c b/drivers/staging/vme_user/vme_fake.c
> index 731fbba17..506bc5439 100644
> --- a/drivers/staging/vme_user/vme_fake.c
> +++ b/drivers/staging/vme_user/vme_fake.c
> @@ -1029,9 +1029,9 @@ static int fake_crcsr_init(struct vme_bridge *fake_bridge)
>  
>  	/* Allocate mem for CR/CSR image */
>  	bridge->crcsr_kernel = kzalloc(VME_CRCSR_BUF_SIZE, GFP_KERNEL);
> -	bridge->crcsr_bus = fake_ptr_to_pci(bridge->crcsr_kernel);
>  	if (!bridge->crcsr_kernel)
>  		return -ENOMEM;
> +	bridge->crcsr_bus = fake_ptr_to_pci(bridge->crcsr_kernel);

As this isn't actually a bugfix, and if an automated tool can't handle
something as simple as this it's really broken, I think we should just
leave this alone for now.

thanks,

greg k-h

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

end of thread, other threads:[~2026-02-08  6:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-07 21:55 [PATCH] staging: vme_user: reorder NULL check after kzalloc in fake_crcsr_init Artem Lytkin
2026-02-08  2:33 ` Ethan Tidmore
2026-02-08  6:35 ` Greg Kroah-Hartman

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