Commit 26c8f0d601f5d4c0d9f4bc8c5151539aae5dc26a

Authored by Jeff Layton
Committed by Steve French
1 parent 83e3bc23ef

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: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Pavel Shilovsky <piastry@etersoft.ru>
Signed-off-by: Steve French <smfrench@gmail.com>

Showing 2 changed files with 2 additions and 8 deletions Side-by-side Diff

... ... @@ -1068,7 +1068,7 @@
1068 1068 unsigned int pagesz;
1069 1069 unsigned int tailsz;
1070 1070 unsigned int nr_pages;
1071   - struct page *pages[1];
  1071 + struct page *pages[];
1072 1072 };
1073 1073  
1074 1074 /*
... ... @@ -1962,15 +1962,9 @@
1962 1962 {
1963 1963 struct cifs_writedata *wdata;
1964 1964  
1965   - /* this would overflow */
1966   - if (nr_pages == 0) {
1967   - cifs_dbg(VFS, "%s: called with nr_pages == 0!\n", __func__);
1968   - return NULL;
1969   - }
1970   -
1971 1965 /* writedata + number of page pointers */
1972 1966 wdata = kzalloc(sizeof(*wdata) +
1973   - sizeof(struct page *) * (nr_pages - 1), GFP_NOFS);
  1967 + sizeof(struct page *) * nr_pages, GFP_NOFS);
1974 1968 if (wdata != NULL) {
1975 1969 kref_init(&wdata->refcount);
1976 1970 INIT_LIST_HEAD(&wdata->list);