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/rpmsg/qcom_smd.c | |
| 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/rpmsg/qcom_smd.c')
| -rw-r--r-- | drivers/rpmsg/qcom_smd.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c index 42594f5ee438..7faed3530888 100644 --- a/drivers/rpmsg/qcom_smd.c +++ b/drivers/rpmsg/qcom_smd.c @@ -922,7 +922,7 @@ static struct rpmsg_endpoint *qcom_smd_create_ept(struct rpmsg_device *rpdev, return NULL; } - qsept = kzalloc(sizeof(*qsept), GFP_KERNEL); + qsept = kzalloc_obj(*qsept, GFP_KERNEL); if (!qsept) return NULL; @@ -1077,7 +1077,7 @@ static int qcom_smd_create_device(struct qcom_smd_channel *channel) dev_dbg(&edge->dev, "registering '%s'\n", channel->name); - qsdev = kzalloc(sizeof(*qsdev), GFP_KERNEL); + qsdev = kzalloc_obj(*qsdev, GFP_KERNEL); if (!qsdev) return -ENOMEM; @@ -1104,7 +1104,7 @@ static int qcom_smd_create_chrdev(struct qcom_smd_edge *edge) { struct qcom_smd_device *qsdev; - qsdev = kzalloc(sizeof(*qsdev), GFP_KERNEL); + qsdev = kzalloc_obj(*qsdev, GFP_KERNEL); if (!qsdev) return -ENOMEM; @@ -1132,7 +1132,7 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed void *info; int ret; - channel = kzalloc(sizeof(*channel), GFP_KERNEL); + channel = kzalloc_obj(*channel, GFP_KERNEL); if (!channel) return ERR_PTR(-ENOMEM); @@ -1484,7 +1484,7 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent, if (!qcom_smem_is_available()) return ERR_PTR(-EPROBE_DEFER); - edge = kzalloc(sizeof(*edge), GFP_KERNEL); + edge = kzalloc_obj(*edge, GFP_KERNEL); if (!edge) return ERR_PTR(-ENOMEM); |
