Commit 26c8f0d6 authored by Jeff Layton's avatar Jeff Layton Committed by Steve French

cifs: use a flexarray in cifs_writedata

The cifs_writedata code uses a single element trailing array, which
just adds unneeded complexity. Use a flexarray instead.
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Reviewed-by: default avatarPavel Shilovsky <piastry@etersoft.ru>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
parent 83e3bc23
...@@ -1068,7 +1068,7 @@ struct cifs_writedata { ...@@ -1068,7 +1068,7 @@ struct cifs_writedata {
unsigned int pagesz; unsigned int pagesz;
unsigned int tailsz; unsigned int tailsz;
unsigned int nr_pages; unsigned int nr_pages;
struct page *pages[1]; struct page *pages[];
}; };
/* /*
......
...@@ -1962,15 +1962,9 @@ cifs_writedata_alloc(unsigned int nr_pages, work_func_t complete) ...@@ -1962,15 +1962,9 @@ cifs_writedata_alloc(unsigned int nr_pages, work_func_t complete)
{ {
struct cifs_writedata *wdata; struct cifs_writedata *wdata;
/* this would overflow */
if (nr_pages == 0) {
cifs_dbg(VFS, "%s: called with nr_pages == 0!\n", __func__);
return NULL;
}
/* writedata + number of page pointers */ /* writedata + number of page pointers */
wdata = kzalloc(sizeof(*wdata) + wdata = kzalloc(sizeof(*wdata) +
sizeof(struct page *) * (nr_pages - 1), GFP_NOFS); sizeof(struct page *) * nr_pages, GFP_NOFS);
if (wdata != NULL) { if (wdata != NULL) {
kref_init(&wdata->refcount); kref_init(&wdata->refcount);
INIT_LIST_HEAD(&wdata->list); INIT_LIST_HEAD(&wdata->list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment