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/auxdisplay | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | linux-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz linux-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/auxdisplay')
| -rw-r--r-- | drivers/auxdisplay/hd44780.c | 2 | ||||
| -rw-r--r-- | drivers/auxdisplay/line-display.c | 4 | ||||
| -rw-r--r-- | drivers/auxdisplay/panel.c | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c index cef42656c4b0..aee1f5a60c0d 100644 --- a/drivers/auxdisplay/hd44780.c +++ b/drivers/auxdisplay/hd44780.c @@ -226,7 +226,7 @@ static int hd44780_probe(struct platform_device *pdev) if (!lcd) return -ENOMEM; - hd = kzalloc(sizeof(*hd), GFP_KERNEL); + hd = kzalloc_obj(*hd, GFP_KERNEL); if (!hd) goto fail2; diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-display.c index 4e22373fcc1a..d3860953b0de 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -56,7 +56,7 @@ static int create_attachment(struct device *dev, struct linedisp *linedisp, bool { struct linedisp_attachment *attachment; - attachment = kzalloc(sizeof(*attachment), GFP_KERNEL); + attachment = kzalloc_obj(*attachment, GFP_KERNEL); if (!attachment) return -ENOMEM; @@ -390,7 +390,7 @@ static int linedisp_init_map(struct linedisp *linedisp) if (err < 0) return err; - map = kmalloc(sizeof(*map), GFP_KERNEL); + map = kmalloc_obj(*map, GFP_KERNEL); if (!map) return -ENOMEM; diff --git a/drivers/auxdisplay/panel.c b/drivers/auxdisplay/panel.c index 958c0e31e84a..8aad34f96068 100644 --- a/drivers/auxdisplay/panel.c +++ b/drivers/auxdisplay/panel.c @@ -1428,7 +1428,7 @@ static struct logical_input *panel_bind_key(const char *name, const char *press, { struct logical_input *key; - key = kzalloc(sizeof(*key), GFP_KERNEL); + key = kzalloc_obj(*key, GFP_KERNEL); if (!key) return NULL; |
