* [PATCH RESEND] staging: vme_user: reorder NULL check after kzalloc in fake_crcsr_init
@ 2026-07-23 16:18 Artem Lytkin
2026-07-28 7:19 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Artem Lytkin @ 2026-07-23 16:18 UTC (permalink / raw)
To: linux-staging; +Cc: gregkh
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 434cf760ade6c..5a4e61d204796 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] 2+ messages in thread
* Re: [PATCH RESEND] staging: vme_user: reorder NULL check after kzalloc in fake_crcsr_init
2026-07-23 16:18 [PATCH RESEND] staging: vme_user: reorder NULL check after kzalloc in fake_crcsr_init Artem Lytkin
@ 2026-07-28 7:19 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2026-07-28 7:19 UTC (permalink / raw)
To: Artem Lytkin; +Cc: linux-staging
On Thu, Jul 23, 2026 at 07:18:46PM +0300, 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.
Let's worry about that in the future, as this does not actually do
anything at all.
>
> 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 434cf760ade6c..5a4e61d204796 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);
Again, assigning NULL to a value is just fine.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-28 7:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-23 16:18 [PATCH RESEND] staging: vme_user: reorder NULL check after kzalloc in fake_crcsr_init Artem Lytkin
2026-07-28 7:19 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox