diff options
| author | Kees Cook <[email protected]> | 2018-05-08 22:56:34 +0000 |
|---|---|---|
| committer | Kees Cook <[email protected]> | 2018-06-06 18:15:43 +0000 |
| commit | b4b06db115bbbc10252287ae2d326fb5ecefaf18 (patch) | |
| tree | 708187c4aea456a9546f7c1ab30061882d839789 /net/ipv4/tcp_ipv4.c | |
| parent | treewide: Use struct_size() for kmalloc()-family (diff) | |
| download | kernel-b4b06db115bbbc10252287ae2d326fb5ecefaf18.tar.gz kernel-b4b06db115bbbc10252287ae2d326fb5ecefaf18.zip | |
treewide: Use struct_size() for vmalloc()-family
This only finds one hit in the entire tree, but here's the Coccinelle:
// Directly refer to structure's field
@@
identifier alloc =~ "vmalloc|vzalloc";
identifier VAR, ELEMENT;
expression COUNT;
@@
- alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT))
+ alloc(struct_size(VAR, ELEMENT, COUNT))
// mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
@@
identifier alloc =~ "vmalloc|vzalloc";
identifier VAR, ELEMENT;
expression COUNT;
@@
- alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]))
+ alloc(struct_size(VAR, ELEMENT, COUNT))
// Same pattern, but can't trivially locate the trailing element name,
// or variable name.
@@
identifier alloc =~ "vmalloc|vzalloc";
expression SOMETHING, COUNT, ELEMENT;
@@
- alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT))
+ alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT))
Signed-off-by: Kees Cook <[email protected]>
Diffstat (limited to 'net/ipv4/tcp_ipv4.c')
0 files changed, 0 insertions, 0 deletions
