[PATCH] staging: media: atomisp: use kvcalloc() in ia_css_refcount_init()
From: Shaunak Datar
Date: Sat Dec 05 2026 - 01:58:37 EST
ia_css_refcount_init() was using kvmalloc() and memset(), update that to
use kvcalloc() which returns zeroed memory.
Signed-off-by: Shaunak Datar <shaunakkdatar@xxxxxxxxx>
---
.../atomisp/pci/base/refcount/src/refcount.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c b/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c
index 168180f3873e..b4be21955245 100644
--- a/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c
+++ b/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c
@@ -59,8 +59,6 @@ static struct ia_css_refcount_entry *refcount_find_entry(ia_css_ptr ptr,
int ia_css_refcount_init(uint32_t size)
{
- int err = 0;
-
if (size == 0) {
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
"%s(): Size of 0 for Ref count init!\n", __func__);
@@ -71,16 +69,12 @@ int ia_css_refcount_init(uint32_t size)
"%s(): Ref count is already initialized\n", __func__);
return -EINVAL;
}
- myrefcount.items =
- kvmalloc(sizeof(struct ia_css_refcount_entry) * size, GFP_KERNEL);
+ myrefcount.items = kvcalloc(size, sizeof(struct ia_css_refcount_entry), GFP_KERNEL);
if (!myrefcount.items)
- err = -ENOMEM;
- if (!err) {
- memset(myrefcount.items, 0,
- sizeof(struct ia_css_refcount_entry) * size);
- myrefcount.size = size;
- }
- return err;
+ return -ENOMEM;
+
+ myrefcount.size = size;
+ return 0;
}
void ia_css_refcount_uninit(void)
--
2.53.0