Skip to content

Commit 26c8f0d

Browse files
jtlaytonsmfrench
authored andcommitted
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 <[email protected]> Reviewed-by: Pavel Shilovsky <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 83e3bc2 commit 26c8f0d

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

fs/cifs/cifsglob.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ struct cifs_writedata {
10681068
unsigned int pagesz;
10691069
unsigned int tailsz;
10701070
unsigned int nr_pages;
1071-
struct page *pages[1];
1071+
struct page *pages[];
10721072
};
10731073

10741074
/*

fs/cifs/cifssmb.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,15 +1962,9 @@ cifs_writedata_alloc(unsigned int nr_pages, work_func_t complete)
19621962
{
19631963
struct cifs_writedata *wdata;
19641964

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-
19711965
/* writedata + number of page pointers */
19721966
wdata = kzalloc(sizeof(*wdata) +
1973-
sizeof(struct page *) * (nr_pages - 1), GFP_NOFS);
1967+
sizeof(struct page *) * nr_pages, GFP_NOFS);
19741968
if (wdata != NULL) {
19751969
kref_init(&wdata->refcount);
19761970
INIT_LIST_HEAD(&wdata->list);

0 commit comments

Comments
 (0)