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/s390/virtio | |
| 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/s390/virtio')
| -rw-r--r-- | drivers/s390/virtio/virtio_ccw.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c index 1653cc668dcf..ae36a1f410a5 100644 --- a/drivers/s390/virtio/virtio_ccw.c +++ b/drivers/s390/virtio/virtio_ccw.c @@ -277,7 +277,7 @@ static struct airq_info *new_airq_info(int index) struct airq_info *info; int rc; - info = kzalloc(sizeof(*info), GFP_KERNEL); + info = kzalloc_obj(*info, GFP_KERNEL); if (!info) return NULL; rwlock_init(&info->lock); @@ -566,7 +566,7 @@ static struct virtqueue *virtio_ccw_setup_vq(struct virtio_device *vdev, notify = virtio_ccw_kvm_notify; /* Allocate queue. */ - info = kzalloc(sizeof(struct virtio_ccw_vq_info), GFP_KERNEL); + info = kzalloc_obj(struct virtio_ccw_vq_info, GFP_KERNEL); if (!info) { dev_warn(&vcdev->cdev->dev, "no info\n"); err = -ENOMEM; @@ -1370,7 +1370,7 @@ static int virtio_ccw_online(struct ccw_device *cdev) struct virtio_ccw_device *vcdev; unsigned long flags; - vcdev = kzalloc(sizeof(*vcdev), GFP_KERNEL); + vcdev = kzalloc_obj(*vcdev, GFP_KERNEL); if (!vcdev) { dev_warn(&cdev->dev, "Could not get memory for virtio\n"); ret = -ENOMEM; |
