linux/net/ceph
Gustavo A. R. Silva 6b41d4d9cb libceph: use struct_size() for kmalloc() in crush_decode()
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct foo {
    int stuff;
    struct boo entry[];
};

instance = kmalloc(sizeof(struct foo) + count * sizeof(struct boo), GFP_KERNEL);

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2019-03-05 18:55:17 +01:00
..
crush
Kconfig
Makefile
armor.c
auth.c
auth_none.c
auth_none.h
auth_x.c
auth_x.h
auth_x_protocol.h
buffer.c
ceph_common.c libceph: allow setting abort_on_full for rbd 2019-01-07 22:47:48 +01:00
ceph_fs.c
ceph_hash.c
ceph_strings.c
cls_lock_client.c
crypto.c
crypto.h
debugfs.c libceph: allow setting abort_on_full for rbd 2019-01-07 22:47:48 +01:00
messenger.c libceph: handle an empty authorize reply 2019-02-18 18:05:33 +01:00
mon_client.c
msgpool.c
osd_client.c libceph: allow setting abort_on_full for rbd 2019-01-07 22:47:48 +01:00
osdmap.c libceph: use struct_size() for kmalloc() in crush_decode() 2019-03-05 18:55:17 +01:00
pagelist.c
pagevec.c
snapshot.c
string_table.c
striper.c