* [PATCH 1/2] platform/raspberrypi: vc-sm-cma: Fix get_kernel_id check, pass NULL for pointer
2026-11-16 13:32 [PATCH 0/2] platform/raspberrypi: vc-sm-cma: Fix sparse and smatch warnings Jai Luthra
@ 2026-11-16 13:32 ` Jai Luthra
2026-11-16 23:01 ` Florian Fainelli
2026-11-16 13:32 ` [PATCH 2/2] platform/raspberrypi: vchiq-mmal: Fix warnings in the zero-copy path Jai Luthra
2026-11-16 23:03 ` [PATCH 0/2] platform/raspberrypi: vc-sm-cma: Fix sparse and smatch warnings Florian Fainelli
2 siblings, 1 reply; 6+ messages in thread
From: Jai Luthra @ 2026-11-16 13:32 UTC (permalink / raw)
To: Florian Fainelli, Raspberry Pi Kernel Maintenance,
Broadcom internal kernel review list, Dave Stevenson
Cc: Stefan Wahren, Dom Cobley, Phil Elwell, Kieran Bingham,
Laurent Pinchart, Juerg Haefliger, linux-kernel,
linux-rpi-kernel, linux-arm-kernel, Jai Luthra,
kernel test robot
Fix a couple of issues reported by sparse on the vc-sm-cma driver.
The first is around the retval of get_kernel_id(), which we check for
negative error codes after assigning it to a u32 value. Fix it by using
a temporary signed integer for the check. While at it, also ensure
during error handling that we call free_kernel_id() only if we got a
valid one earlier.
The second is a minor warning around passing 0 instead of NULL for a
pointer argument.
Fixes: 0d6409fd70af ("platform/raspberrypi: Add VideoCore shared memory support")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202611141042.Rxt6cuNo-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202611141002.jCrJ06DU-lkp@intel.com/
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/platform/raspberrypi/vc-sm-cma/vc_sm.c | 11 +++++++----
drivers/platform/raspberrypi/vc-sm-cma/vc_sm_cma_vchi.c | 2 +-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/raspberrypi/vc-sm-cma/vc_sm.c b/drivers/platform/raspberrypi/vc-sm-cma/vc_sm.c
index 4dda06fee533..2d9bb5f957a3 100644
--- a/drivers/platform/raspberrypi/vc-sm-cma/vc_sm.c
+++ b/drivers/platform/raspberrypi/vc-sm-cma/vc_sm.c
@@ -415,6 +415,7 @@ vc_sm_cma_import_dmabuf_internal(struct dma_buf *dma_buf,
struct vc_sm_import import = { };
struct sg_table *sgt = NULL;
dma_addr_t dma_addr;
+ int kernel_id = -1;
u32 cache_alias;
int ret = 0;
int status;
@@ -469,11 +470,12 @@ vc_sm_cma_import_dmabuf_internal(struct dma_buf *dma_buf,
}
import.size = sg_dma_len(sgt->sgl);
import.allocator = current->tgid;
- import.kernel_id = get_kernel_id(buffer);
- if (import.kernel_id < 0) {
- ret = import.kernel_id;
+ kernel_id = get_kernel_id(buffer);
+ if (kernel_id < 0) {
+ ret = kernel_id;
goto error;
}
+ import.kernel_id = kernel_id;
memcpy(import.name, VC_SM_RESOURCE_NAME_DEFAULT,
sizeof(VC_SM_RESOURCE_NAME_DEFAULT));
@@ -544,7 +546,8 @@ vc_sm_cma_import_dmabuf_internal(struct dma_buf *dma_buf,
vc_sm_cma_vchi_free(sm_state->sm_handle, &free,
&sm_state->int_trans_id);
}
- free_kernel_id(import.kernel_id);
+ if (kernel_id >= 0)
+ free_kernel_id(import.kernel_id);
kfree(buffer);
if (sgt)
dma_buf_unmap_attachment_unlocked(attach, sgt,
diff --git a/drivers/platform/raspberrypi/vc-sm-cma/vc_sm_cma_vchi.c b/drivers/platform/raspberrypi/vc-sm-cma/vc_sm_cma_vchi.c
index 098342601895..54d318735575 100644
--- a/drivers/platform/raspberrypi/vc-sm-cma/vc_sm_cma_vchi.c
+++ b/drivers/platform/raspberrypi/vc-sm-cma/vc_sm_cma_vchi.c
@@ -481,7 +481,7 @@ int vc_sm_cma_vchi_free(struct sm_instance *handle, struct vc_sm_free_t *msg,
u32 *cur_trans_id)
{
return vc_sm_cma_vchi_send_msg(handle, VC_SM_MSG_TYPE_FREE,
- msg, sizeof(*msg), 0, 0, cur_trans_id, 0);
+ msg, sizeof(*msg), NULL, 0, cur_trans_id, 0);
}
int vc_sm_cma_vchi_import(struct sm_instance *handle, struct vc_sm_import *msg,
--
2.56.0
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 1/2] platform/raspberrypi: vc-sm-cma: Fix get_kernel_id check, pass NULL for pointer
2026-11-16 13:32 ` [PATCH 1/2] platform/raspberrypi: vc-sm-cma: Fix get_kernel_id check, pass NULL for pointer Jai Luthra
@ 2026-11-16 23:01 ` Florian Fainelli
0 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2026-11-16 23:01 UTC (permalink / raw)
To: bcm-kernel-feedback-list, Jai Luthra, Florian Fainelli,
Raspberry Pi Kernel Maintenance, Dave Stevenson
Cc: Florian Fainelli, Stefan Wahren, Dom Cobley, Phil Elwell,
Kieran Bingham, Laurent Pinchart, Juerg Haefliger, linux-kernel,
linux-rpi-kernel, linux-arm-kernel, kernel test robot
From: Florian Fainelli <f.fainelli@gmail.com>
On Mon, 16 Nov 2026 19:02:53 +0530, Jai Luthra <jai.luthra@ideasonboard.com> wrote:
> Fix a couple of issues reported by sparse on the vc-sm-cma driver.
>
> The first is around the retval of get_kernel_id(), which we check for
> negative error codes after assigning it to a u32 value. Fix it by using
> a temporary signed integer for the check. While at it, also ensure
> during error handling that we call free_kernel_id() only if we got a
> valid one earlier.
>
> The second is a minor warning around passing 0 instead of NULL for a
> pointer argument.
>
> Fixes: 0d6409fd70af ("platform/raspberrypi: Add VideoCore shared memory support")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202611141042.Rxt6cuNo-lkp@intel.com/
> Closes: https://lore.kernel.org/oe-kbuild-all/202611141002.jCrJ06DU-lkp@intel.com/
> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
> ---
Applied to https://github.com/Broadcom/stblinux/commits/drivers/next, thanks!
--
Florian
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] platform/raspberrypi: vchiq-mmal: Fix warnings in the zero-copy path
2026-11-16 13:32 [PATCH 0/2] platform/raspberrypi: vc-sm-cma: Fix sparse and smatch warnings Jai Luthra
2026-11-16 13:32 ` [PATCH 1/2] platform/raspberrypi: vc-sm-cma: Fix get_kernel_id check, pass NULL for pointer Jai Luthra
@ 2026-11-16 13:32 ` Jai Luthra
2026-11-16 23:01 ` Florian Fainelli
2026-11-16 23:03 ` [PATCH 0/2] platform/raspberrypi: vc-sm-cma: Fix sparse and smatch warnings Florian Fainelli
2 siblings, 1 reply; 6+ messages in thread
From: Jai Luthra @ 2026-11-16 13:32 UTC (permalink / raw)
To: Florian Fainelli, Raspberry Pi Kernel Maintenance,
Broadcom internal kernel review list, Dave Stevenson
Cc: Stefan Wahren, Dom Cobley, Phil Elwell, Kieran Bingham,
Laurent Pinchart, Juerg Haefliger, linux-kernel,
linux-rpi-kernel, linux-arm-kernel, Jai Luthra,
kernel test robot, Dan Carpenter
Fix minor issues reported by sparse and smatch around the zero-copy
support added in mmal-vchiq.
If there is no handle present vc_sm_cma_get_vc_handle() might fail,
which we check but end up printing and returing the value of the
undefined `ret` variable. Fix it by returning -EINVAL and dropping `ret`
from the print.
While at it, also fix the stale reference to the function name
"vc_sm_int_handle" in the error print, which was renamed to
"vc_sm_cma_get_vc_handle".
Secondly, during cleanup assign NULL instead of 0 to buf->vcsm_handle,
which is a pointer.
Fixes: 67d0fbe47f8a ("platform/raspberrypi: vchiq-mmal: Use vc-sm-cma to support zero copy")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202611141210.9hmxzD2V-lkp@intel.com/
Closes: https://lore.kernel.org/r/202611141218.5FZTnFtc-lkp@intel.com/
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c b/drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c
index 8d765aa7ea12..46803ef1e071 100644
--- a/drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c
+++ b/drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c
@@ -1644,10 +1644,10 @@ int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
buffer->vc_handle = vc_sm_cma_get_vc_handle(buffer->vcsm_handle);
if (!buffer->vc_handle) {
- pr_err("%s: vc_sm_int_handle failed %d\n",
- __func__, ret);
+ pr_err("%s: vc_sm_cma_get_vc_handle failed\n",
+ __func__);
vc_sm_cma_free(buffer->vcsm_handle);
- return ret;
+ return -EINVAL;
}
pr_debug("%s: import dmabuf %p - got vc handle %08X\n",
__func__, buffer->dma_buf, buffer->vc_handle);
@@ -1694,7 +1694,7 @@ int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf)
ret = vc_sm_cma_free(buf->vcsm_handle);
if (ret)
pr_err("%s: vcsm_free failed, ret %d\n", __func__, ret);
- buf->vcsm_handle = 0;
+ buf->vcsm_handle = NULL;
}
return 0;
}
--
2.56.0
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 2/2] platform/raspberrypi: vchiq-mmal: Fix warnings in the zero-copy path
2026-11-16 13:32 ` [PATCH 2/2] platform/raspberrypi: vchiq-mmal: Fix warnings in the zero-copy path Jai Luthra
@ 2026-11-16 23:01 ` Florian Fainelli
0 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2026-11-16 23:01 UTC (permalink / raw)
To: bcm-kernel-feedback-list, Jai Luthra, Florian Fainelli,
Raspberry Pi Kernel Maintenance, Dave Stevenson
Cc: Florian Fainelli, Stefan Wahren, Dom Cobley, Phil Elwell,
Kieran Bingham, Laurent Pinchart, Juerg Haefliger, linux-kernel,
linux-rpi-kernel, linux-arm-kernel, kernel test robot,
Dan Carpenter
From: Florian Fainelli <f.fainelli@gmail.com>
On Mon, 16 Nov 2026 19:02:54 +0530, Jai Luthra <jai.luthra@ideasonboard.com> wrote:
> Fix minor issues reported by sparse and smatch around the zero-copy
> support added in mmal-vchiq.
>
> If there is no handle present vc_sm_cma_get_vc_handle() might fail,
> which we check but end up printing and returing the value of the
> undefined `ret` variable. Fix it by returning -EINVAL and dropping `ret`
> from the print.
>
> While at it, also fix the stale reference to the function name
> "vc_sm_int_handle" in the error print, which was renamed to
> "vc_sm_cma_get_vc_handle".
>
> Secondly, during cleanup assign NULL instead of 0 to buf->vcsm_handle,
> which is a pointer.
>
> Fixes: 67d0fbe47f8a ("platform/raspberrypi: vchiq-mmal: Use vc-sm-cma to support zero copy")
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <error27@gmail.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202611141210.9hmxzD2V-lkp@intel.com/
> Closes: https://lore.kernel.org/r/202611141218.5FZTnFtc-lkp@intel.com/
> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
> ---
Applied to https://github.com/Broadcom/stblinux/commits/drivers/next, thanks!
--
Florian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] platform/raspberrypi: vc-sm-cma: Fix sparse and smatch warnings
2026-11-16 13:32 [PATCH 0/2] platform/raspberrypi: vc-sm-cma: Fix sparse and smatch warnings Jai Luthra
2026-11-16 13:32 ` [PATCH 1/2] platform/raspberrypi: vc-sm-cma: Fix get_kernel_id check, pass NULL for pointer Jai Luthra
2026-11-16 13:32 ` [PATCH 2/2] platform/raspberrypi: vchiq-mmal: Fix warnings in the zero-copy path Jai Luthra
@ 2026-11-16 23:03 ` Florian Fainelli
2 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2026-11-16 23:03 UTC (permalink / raw)
To: Jai Luthra, Raspberry Pi Kernel Maintenance,
Broadcom internal kernel review list, Dave Stevenson
Cc: Stefan Wahren, Dom Cobley, Phil Elwell, Kieran Bingham,
Laurent Pinchart, Juerg Haefliger, linux-kernel,
linux-rpi-kernel, linux-arm-kernel, kernel test robot,
Dan Carpenter
On 11/16/26 05:32, Jai Luthra wrote:
> Hi Florian,
>
> I've fixed the issues reported by sparse and smatch on my series that
> added shared memory support for VC4 based peripherals in Raspberry Pi 4.
>
> My apologies for not running those checks on my machine before sending.
>
> As those patches are now applied in your tree, I have added Fixes tags
> using the SHAs for the applied commits.
>
> Thanks,
> Jai
Thanks for the quick follow-up, I fixed up both commits into the commit
they have in the Fixes tag since this was only in my drivers/next branch.
--
Florian
^ permalink raw reply [flat|nested] 6+ messages in thread