diff options
author | Zhengyuan Liu <liuzhengyuan@kylinos.cn> | 2019-06-20 13:12:17 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2019-06-20 13:12:17 -0400 |
commit | ee102584efd53547bf9a0810e80b56f99f4a9105 (patch) | |
tree | cd995a1511e4aa4c9ef6d2a488795d5a5b670693 | |
parent | 452181936931f0f08923aba5e04e1e9ef58c389f (diff) |
fs/afs: use struct_size() in kzalloc()
As Gustavo said in other patches doing the same replace, we can now
use the new struct_size() helper to avoid leaving these open-coded and
prone to type mistake.
Signed-off-by: Zhengyuan Liu <liuzhengyuan@kylinos.cn>
Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r-- | fs/afs/dir.c | 3 | ||||
-rw-r--r-- | fs/afs/file.c | 6 | ||||
-rw-r--r-- | fs/afs/write.c | 3 |
3 files changed, 4 insertions, 8 deletions
diff --git a/fs/afs/dir.c b/fs/afs/dir.c index e8c58c94eb61..5dff607a08f9 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c | |||
@@ -242,8 +242,7 @@ retry: | |||
242 | if (nr_inline > (PAGE_SIZE - sizeof(*req)) / sizeof(struct page *)) | 242 | if (nr_inline > (PAGE_SIZE - sizeof(*req)) / sizeof(struct page *)) |
243 | nr_inline = 0; | 243 | nr_inline = 0; |
244 | 244 | ||
245 | req = kzalloc(sizeof(*req) + sizeof(struct page *) * nr_inline, | 245 | req = kzalloc(struct_size(req, array, nr_inline), GFP_KERNEL); |
246 | GFP_KERNEL); | ||
247 | if (!req) | 246 | if (!req) |
248 | return ERR_PTR(-ENOMEM); | 247 | return ERR_PTR(-ENOMEM); |
249 | 248 | ||
diff --git a/fs/afs/file.c b/fs/afs/file.c index 11e69c5fb7ab..67cd782a1c64 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c | |||
@@ -314,8 +314,7 @@ int afs_page_filler(void *data, struct page *page) | |||
314 | /* fall through */ | 314 | /* fall through */ |
315 | default: | 315 | default: |
316 | go_on: | 316 | go_on: |
317 | req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *), | 317 | req = kzalloc(struct_size(req, array, 1), GFP_KERNEL); |
318 | GFP_KERNEL); | ||
319 | if (!req) | 318 | if (!req) |
320 | goto enomem; | 319 | goto enomem; |
321 | 320 | ||
@@ -465,8 +464,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping, | |||
465 | n++; | 464 | n++; |
466 | } | 465 | } |
467 | 466 | ||
468 | req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *) * n, | 467 | req = kzalloc(struct_size(req, array, n), GFP_NOFS); |
469 | GFP_NOFS); | ||
470 | if (!req) | 468 | if (!req) |
471 | return -ENOMEM; | 469 | return -ENOMEM; |
472 | 470 | ||
diff --git a/fs/afs/write.c b/fs/afs/write.c index 8bcab95f1127..9cea9c40a4ef 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c | |||
@@ -48,8 +48,7 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key, | |||
48 | return 0; | 48 | return 0; |
49 | } | 49 | } |
50 | 50 | ||
51 | req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *), | 51 | req = kzalloc(struct_size(req, array, 1), GFP_KERNEL); |
52 | GFP_KERNEL); | ||
53 | if (!req) | 52 | if (!req) |
54 | return -ENOMEM; | 53 | return -ENOMEM; |
55 | 54 | ||