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/omap2 | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.zip | |
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/omap2')
| -rw-r--r-- | drivers/video/fbdev/omap2/omapfb/dss/dsi.c | 2 | ||||
| -rw-r--r-- | drivers/video/fbdev/omap2/omapfb/dss/manager.c | 4 | ||||
| -rw-r--r-- | drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c | 5 | ||||
| -rw-r--r-- | drivers/video/fbdev/omap2/omapfb/dss/overlay.c | 3 | ||||
| -rw-r--r-- | drivers/video/fbdev/omap2/omapfb/omapfb-main.c | 8 |
5 files changed, 10 insertions, 12 deletions
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c index 370e8623754e..19498b7ccb14 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c @@ -1539,7 +1539,7 @@ static void dsi_dump_dsidev_irqs(struct platform_device *dsidev, unsigned long flags; struct dsi_irq_stats *stats; - stats = kzalloc(sizeof(*stats), GFP_KERNEL); + stats = kzalloc_obj(*stats, GFP_KERNEL); if (!stats) { seq_printf(s, "out of memory\n"); return; diff --git a/drivers/video/fbdev/omap2/omapfb/dss/manager.c b/drivers/video/fbdev/omap2/omapfb/dss/manager.c index c59e5689d6cc..0fc5d43c58ff 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/manager.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/manager.c @@ -32,8 +32,8 @@ int dss_init_overlay_managers(void) num_managers = dss_feat_get_num_mgrs(); - managers = kcalloc(num_managers, sizeof(struct omap_overlay_manager), - GFP_KERNEL); + managers = kzalloc_objs(struct omap_overlay_manager, num_managers, + GFP_KERNEL); BUG_ON(managers == NULL); diff --git a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c index d80720c84323..098c02164428 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c @@ -46,7 +46,7 @@ static void __init omapdss_update_prop(struct device_node *node, char *compat, { struct property *prop; - prop = kzalloc(sizeof(*prop), GFP_KERNEL); + prop = kzalloc_obj(*prop, GFP_KERNEL); if (!prop) return; @@ -110,8 +110,7 @@ static void __init omapdss_omapify_node(struct device_node *node) static void __init omapdss_add_to_list(struct device_node *node, bool root) { - struct dss_conv_node *n = kmalloc(sizeof(struct dss_conv_node), - GFP_KERNEL); + struct dss_conv_node *n = kmalloc_obj(struct dss_conv_node, GFP_KERNEL); if (n) { n->node = node; n->root = root; diff --git a/drivers/video/fbdev/omap2/omapfb/dss/overlay.c b/drivers/video/fbdev/omap2/omapfb/dss/overlay.c index bbbdc233ee61..cb2a230c57a1 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/overlay.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/overlay.c @@ -49,8 +49,7 @@ void dss_init_overlays(struct platform_device *pdev) num_overlays = dss_feat_get_num_ovls(); - overlays = kcalloc(num_overlays, sizeof(struct omap_overlay), - GFP_KERNEL); + overlays = kzalloc_objs(struct omap_overlay, num_overlays, GFP_KERNEL); BUG_ON(overlays == NULL); diff --git a/drivers/video/fbdev/omap2/omapfb/omapfb-main.c b/drivers/video/fbdev/omap2/omapfb/omapfb-main.c index 211f23648686..599a7d6a6114 100644 --- a/drivers/video/fbdev/omap2/omapfb/omapfb-main.c +++ b/drivers/video/fbdev/omap2/omapfb/omapfb-main.c @@ -2023,19 +2023,19 @@ static int omapfb_mode_to_timings(const char *mode_str, var = NULL; fbops = NULL; - fbi = kzalloc(sizeof(*fbi), GFP_KERNEL); + fbi = kzalloc_obj(*fbi, GFP_KERNEL); if (fbi == NULL) { r = -ENOMEM; goto err; } - var = kzalloc(sizeof(*var), GFP_KERNEL); + var = kzalloc_obj(*var, GFP_KERNEL); if (var == NULL) { r = -ENOMEM; goto err; } - fbops = kzalloc(sizeof(*fbops), GFP_KERNEL); + fbops = kzalloc_obj(*fbops, GFP_KERNEL); if (fbops == NULL) { r = -ENOMEM; goto err; @@ -2244,7 +2244,7 @@ static int omapfb_find_best_mode(struct omap_dss_device *display, if (r < 0) goto err1; - specs = kzalloc(sizeof(*specs), GFP_KERNEL); + specs = kzalloc_obj(*specs, GFP_KERNEL); if (specs == NULL) { r = -ENOMEM; goto err1; |
