aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2014-02-07 11:04:04 -0500
committerSteve French <smfrench@gmail.com>2014-02-07 21:38:29 -0500
commit26c8f0d601f5d4c0d9f4bc8c5151539aae5dc26a (patch)
tree54636097b13ebeee398f6b4fe4d98835065ba3b0 /fs
parent83e3bc23ef9ce7c03b7b4e5d3d790246ea59db3e (diff)
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/cifsglob.h2
-rw-r--r--fs/cifs/cifssmb.c8
2 files changed, 2 insertions, 8 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 615e35ab7ef6..d6a031ed391b 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1068,7 +1068,7 @@ struct cifs_writedata {
1068 unsigned int pagesz; 1068 unsigned int pagesz;
1069 unsigned int tailsz; 1069 unsigned int tailsz;
1070 unsigned int nr_pages; 1070 unsigned int nr_pages;
1071 struct page *pages[1]; 1071 struct page *pages[];
1072}; 1072};
1073 1073
1074/* 1074/*
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 4d881c35eeca..0cd742ccb019 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)
1962{ 1962{
1963 struct cifs_writedata *wdata; 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 /* writedata + number of page pointers */ 1965 /* writedata + number of page pointers */
1972 wdata = kzalloc(sizeof(*wdata) + 1966 wdata = kzalloc(sizeof(*wdata) +
1973 sizeof(struct page *) * (nr_pages - 1), GFP_NOFS); 1967 sizeof(struct page *) * nr_pages, GFP_NOFS);
1974 if (wdata != NULL) { 1968 if (wdata != NULL) {
1975 kref_init(&wdata->refcount); 1969 kref_init(&wdata->refcount);
1976 INIT_LIST_HEAD(&wdata->list); 1970 INIT_LIST_HEAD(&wdata->list);