diff options
| author | Gustavo A. R. Silva <[email protected]> | 2019-02-23 12:51:08 -0600 |
|---|---|---|
| committer | Christoph Hellwig <[email protected]> | 2019-04-05 08:07:57 +0200 |
| commit | 6b80f1d2cc5a76f0121a43a612515bc8a8976e66 (patch) | |
| tree | 248338b1b7f50bd9bab7bfd03087c6fbb1ce01ed /tools/perf/scripts/python/exported-sql-viewer.py | |
| parent | cfe03c2ec46200dfefa5167e6a2bb50c0426c5f4 (diff) | |
nvmet-fc: use zero-sized array and struct_size() in kzalloc()
Update the code to use a zero-sized array instead of a pointer in
structure nvmet_fc_tgt_queue and use struct_size() in kzalloc().
Notice that 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 = kzalloc(sizeof(struct foo) + sizeof(struct boo) * count, GFP_KERNEL);
Instead of leaving these open-coded and prone to type mistakes, we can now
use the new struct_size() helper:
instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);
This code was detected with the help of Coccinelle.
Signed-off-by: Gustavo A. R. Silva <[email protected]>
Reviewed-by: James Smart <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
Diffstat (limited to 'tools/perf/scripts/python/exported-sql-viewer.py')
0 files changed, 0 insertions, 0 deletions