Message ID | 1391789044-26179-1-git-send-email-jlayton@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
2014-02-07 20:04 GMT+04:00 Jeff Layton <jlayton@redhat.com>: > 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> > --- > fs/cifs/cifsglob.h | 2 +- > fs/cifs/cifssmb.c | 8 +------- > 2 files changed, 2 insertions(+), 8 deletions(-) > > diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h > index 57d07e704d97..e7fe49e75cdb 100644 > --- a/fs/cifs/cifsglob.h > +++ b/fs/cifs/cifsglob.h > @@ -1064,7 +1064,7 @@ struct cifs_writedata { > unsigned int pagesz; > unsigned int tailsz; > unsigned int nr_pages; > - struct page *pages[1]; > + struct page *pages[]; > }; > > /* > diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c > index 0726ab413b8c..a75b56025df7 100644 > --- a/fs/cifs/cifssmb.c > +++ b/fs/cifs/cifssmb.c > @@ -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); > -- > 1.8.5.3 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-cifs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html Reasonable. Reviewed-by: Pavel Shilovsky <piastry@etersoft.ru>
merged into cifs-2.6.git for-next On Fri, Feb 7, 2014 at 10:04 AM, Jeff Layton <jlayton@redhat.com> wrote: > 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> > --- > fs/cifs/cifsglob.h | 2 +- > fs/cifs/cifssmb.c | 8 +------- > 2 files changed, 2 insertions(+), 8 deletions(-) > > diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h > index 57d07e704d97..e7fe49e75cdb 100644 > --- a/fs/cifs/cifsglob.h > +++ b/fs/cifs/cifsglob.h > @@ -1064,7 +1064,7 @@ struct cifs_writedata { > unsigned int pagesz; > unsigned int tailsz; > unsigned int nr_pages; > - struct page *pages[1]; > + struct page *pages[]; > }; > > /* > diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c > index 0726ab413b8c..a75b56025df7 100644 > --- a/fs/cifs/cifssmb.c > +++ b/fs/cifs/cifssmb.c > @@ -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); > -- > 1.8.5.3 >
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 57d07e704d97..e7fe49e75cdb 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -1064,7 +1064,7 @@ struct cifs_writedata { unsigned int pagesz; unsigned int tailsz; unsigned int nr_pages; - struct page *pages[1]; + struct page *pages[]; }; /* diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 0726ab413b8c..a75b56025df7 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -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);
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> --- fs/cifs/cifsglob.h | 2 +- fs/cifs/cifssmb.c | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-)