cifs: use a flexarray in cifs_writedata
authorJeff Layton <jlayton@redhat.com>
Fri, 7 Feb 2014 16:04:04 +0000 (11:04 -0500)
committerSteve French <smfrench@gmail.com>
Sat, 8 Feb 2014 02:38:29 +0000 (20:38 -0600)
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>
fs/cifs/cifsglob.h
fs/cifs/cifssmb.c

index 615e35ab7ef6c26c420c0421e1bba9e4ff0a5d7f..d6a031ed391b5598bcc28537f181a2c35e9f0e29 100644 (file)
@@ -1068,7 +1068,7 @@ struct cifs_writedata {
        unsigned int                    pagesz;
        unsigned int                    tailsz;
        unsigned int                    nr_pages;
-       struct page                     *pages[1];
+       struct page                     *pages[];
 };
 
 /*
index 4d881c35eecaa035717b52d9c19b9dac00dd9dae..0cd742ccb019e95d081aa082af702e14d649da40 100644 (file)
@@ -1962,15 +1962,9 @@ cifs_writedata_alloc(unsigned int nr_pages, work_func_t complete)
 {
        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 */
        wdata = kzalloc(sizeof(*wdata) +
-                       sizeof(struct page *) * (nr_pages - 1), GFP_NOFS);
+                       sizeof(struct page *) * nr_pages, GFP_NOFS);
        if (wdata != NULL) {
                kref_init(&wdata->refcount);
                INIT_LIST_HEAD(&wdata->list);