summaryrefslogtreecommitdiff
path: root/drivers/media/platform/st
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-20 23:49:23 -0800
committerKees Cook <kees@kernel.org>2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/media/platform/st
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to avoid scalar types (which need careful case-by-case checking), and instead replace kmalloc-family calls that allocate struct or union object instances: Single allocations: kmalloc(sizeof(TYPE), ...) are replaced with: kmalloc_obj(TYPE, ...) Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...) are replaced with: kmalloc_objs(TYPE, COUNT, ...) Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...) are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...) (where TYPE may also be *VAR) The resulting allocations no longer return "void *", instead returning "TYPE *". Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'drivers/media/platform/st')
-rw-r--r--drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c2
-rw-r--r--drivers/media/platform/st/sti/delta/delta-mjpeg-dec.c2
-rw-r--r--drivers/media/platform/st/sti/delta/delta-v4l2.c4
-rw-r--r--drivers/media/platform/st/sti/hva/hva-v4l2.c2
-rw-r--r--drivers/media/platform/st/stm32/dma2d/dma2d.c2
-rw-r--r--drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-bytecap.c2
-rw-r--r--drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c2
-rw-r--r--drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.c2
-rw-r--r--drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-input.c2
9 files changed, 10 insertions, 10 deletions
diff --git a/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
index 56169b70652d..6f7b3f0db48e 100644
--- a/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
@@ -583,7 +583,7 @@ static int bdisp_open(struct file *file)
return -ERESTARTSYS;
/* Allocate memory for both context and node */
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx) {
ret = -ENOMEM;
goto unlock;
diff --git a/drivers/media/platform/st/sti/delta/delta-mjpeg-dec.c b/drivers/media/platform/st/sti/delta/delta-mjpeg-dec.c
index a078f1107300..ed05feac6944 100644
--- a/drivers/media/platform/st/sti/delta/delta-mjpeg-dec.c
+++ b/drivers/media/platform/st/sti/delta/delta-mjpeg-dec.c
@@ -324,7 +324,7 @@ static int delta_mjpeg_open(struct delta_ctx *pctx)
{
struct delta_mjpeg_ctx *ctx;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
pctx->priv = ctx;
diff --git a/drivers/media/platform/st/sti/delta/delta-v4l2.c b/drivers/media/platform/st/sti/delta/delta-v4l2.c
index 6c1a53c771f7..b3fb25bd0f60 100644
--- a/drivers/media/platform/st/sti/delta/delta-v4l2.c
+++ b/drivers/media/platform/st/sti/delta/delta-v4l2.c
@@ -164,7 +164,7 @@ static void delta_push_dts(struct delta_ctx *ctx, u64 val)
{
struct delta_dts *dts;
- dts = kzalloc(sizeof(*dts), GFP_KERNEL);
+ dts = kzalloc_obj(*dts, GFP_KERNEL);
if (!dts)
return;
@@ -1629,7 +1629,7 @@ static int delta_open(struct file *file)
mutex_lock(&delta->lock);
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx) {
ret = -ENOMEM;
goto err;
diff --git a/drivers/media/platform/st/sti/hva/hva-v4l2.c b/drivers/media/platform/st/sti/hva/hva-v4l2.c
index 3581b73a99b8..4b2100b7242b 100644
--- a/drivers/media/platform/st/sti/hva/hva-v4l2.c
+++ b/drivers/media/platform/st/sti/hva/hva-v4l2.c
@@ -1165,7 +1165,7 @@ static int hva_open(struct file *file)
struct hva_ctx *ctx;
int ret;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx) {
ret = -ENOMEM;
goto out;
diff --git a/drivers/media/platform/st/stm32/dma2d/dma2d.c b/drivers/media/platform/st/stm32/dma2d/dma2d.c
index 72488aa922fc..fb11794c6b17 100644
--- a/drivers/media/platform/st/stm32/dma2d/dma2d.c
+++ b/drivers/media/platform/st/stm32/dma2d/dma2d.c
@@ -280,7 +280,7 @@ static int dma2d_open(struct file *file)
struct dma2d_ctx *ctx = NULL;
int ret = 0;
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
ctx->dev = dev;
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-bytecap.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-bytecap.c
index 19e6b187be22..ccf3c19883c0 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-bytecap.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-bytecap.c
@@ -867,7 +867,7 @@ struct dcmipp_ent_device *dcmipp_bytecap_ent_init(struct device *dev,
int ret = 0;
/* Allocate the dcmipp_bytecap_device struct */
- vcap = kzalloc(sizeof(*vcap), GFP_KERNEL);
+ vcap = kzalloc_obj(*vcap, GFP_KERNEL);
if (!vcap)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c
index f9e4a3a9ef3f..4704cc4d6111 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c
@@ -581,7 +581,7 @@ dcmipp_byteproc_ent_init(struct device *dev, const char *entity_name,
int ret;
/* Allocate the byteproc struct */
- byteproc = kzalloc(sizeof(*byteproc), GFP_KERNEL);
+ byteproc = kzalloc_obj(*byteproc, GFP_KERNEL);
if (!byteproc)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.c
index 562933e08d62..f6e83e72c940 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.c
@@ -20,7 +20,7 @@ struct media_pad *dcmipp_pads_init(u16 num_pads, const unsigned long *pads_flags
unsigned int i;
/* Allocate memory for the pads */
- pads = kcalloc(num_pads, sizeof(*pads), GFP_KERNEL);
+ pads = kzalloc_objs(*pads, num_pads, GFP_KERNEL);
if (!pads)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-input.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-input.c
index c4bc76909b1c..ac19ed966521 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-input.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-input.c
@@ -527,7 +527,7 @@ struct dcmipp_ent_device *dcmipp_inp_ent_init(struct device *dev,
int ret;
/* Allocate the inp struct */
- inp = kzalloc(sizeof(*inp), GFP_KERNEL);
+ inp = kzalloc_obj(*inp, GFP_KERNEL);
if (!inp)
return ERR_PTR(-ENOMEM);