diff options
| author | Kees Cook <kees@kernel.org> | 2026-02-20 23:49:23 -0800 |
|---|---|---|
| committer | Kees Cook <kees@kernel.org> | 2026-02-21 01:02:28 -0800 |
| commit | 69050f8d6d075dc01af7a5f2f550a8067510366f (patch) | |
| tree | bb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/video/fbdev/mmp | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (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/video/fbdev/mmp')
| -rw-r--r-- | drivers/video/fbdev/mmp/core.c | 3 | ||||
| -rw-r--r-- | drivers/video/fbdev/mmp/fb/mmpfb.c | 4 | ||||
| -rw-r--r-- | drivers/video/fbdev/mmp/hw/mmp_ctrl.c | 2 | ||||
| -rw-r--r-- | drivers/video/fbdev/mmp/panel/tpo_tj032md01bw.c | 2 |
4 files changed, 5 insertions, 6 deletions
diff --git a/drivers/video/fbdev/mmp/core.c b/drivers/video/fbdev/mmp/core.c index 03707461eced..9e7c138b1290 100644 --- a/drivers/video/fbdev/mmp/core.c +++ b/drivers/video/fbdev/mmp/core.c @@ -155,8 +155,7 @@ struct mmp_path *mmp_register_path(struct mmp_path_info *info) struct mmp_path *path = NULL; struct mmp_panel *panel; - path = kzalloc(struct_size(path, overlays, info->overlay_num), - GFP_KERNEL); + path = kzalloc_flex(*path, overlays, info->overlay_num, GFP_KERNEL); if (!path) return NULL; diff --git a/drivers/video/fbdev/mmp/fb/mmpfb.c b/drivers/video/fbdev/mmp/fb/mmpfb.c index 2d9797c6fb3e..18cef14e6d4c 100644 --- a/drivers/video/fbdev/mmp/fb/mmpfb.c +++ b/drivers/video/fbdev/mmp/fb/mmpfb.c @@ -476,8 +476,8 @@ static int modes_setup(struct mmpfb_info *fbi) return 0; } /* put videomode list to info structure */ - videomodes = kcalloc(videomode_num, sizeof(struct fb_videomode), - GFP_KERNEL); + videomodes = kzalloc_objs(struct fb_videomode, videomode_num, + GFP_KERNEL); if (!videomodes) return -ENOMEM; diff --git a/drivers/video/fbdev/mmp/hw/mmp_ctrl.c b/drivers/video/fbdev/mmp/hw/mmp_ctrl.c index 03e23173198c..2cd152f7a4be 100644 --- a/drivers/video/fbdev/mmp/hw/mmp_ctrl.c +++ b/drivers/video/fbdev/mmp/hw/mmp_ctrl.c @@ -402,7 +402,7 @@ static int path_init(struct mmphw_path_plat *path_plat, dev_info(ctrl->dev, "%s: %s\n", __func__, config->name); /* init driver data */ - path_info = kzalloc(sizeof(*path_info), GFP_KERNEL); + path_info = kzalloc_obj(*path_info, GFP_KERNEL); if (!path_info) return 0; diff --git a/drivers/video/fbdev/mmp/panel/tpo_tj032md01bw.c b/drivers/video/fbdev/mmp/panel/tpo_tj032md01bw.c index 34fae588e202..40194c60987d 100644 --- a/drivers/video/fbdev/mmp/panel/tpo_tj032md01bw.c +++ b/drivers/video/fbdev/mmp/panel/tpo_tj032md01bw.c @@ -144,7 +144,7 @@ static int tpohvga_probe(struct spi_device *spi) return ret; } - plat_data = kzalloc(sizeof(*plat_data), GFP_KERNEL); + plat_data = kzalloc_obj(*plat_data, GFP_KERNEL); if (plat_data == NULL) return -ENOMEM; |
