diff options
| author | Ingo Molnar <mingo@kernel.org> | 2019-04-30 07:51:54 +0200 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2019-04-30 07:51:54 +0200 |
| commit | d5963d87bf84060ff3fb572bf6d3606f7fd087d1 (patch) | |
| tree | 5a94c33a56d7bdd91a38aa0ec50e9202914f742e /fs/cifs/misc.c | |
| parent | 3db6d5a5ecaf0a778d721ccf9809248350d4bfaf (diff) | |
| parent | 37624b58542fb9f2d9a70e6ea006ef8a5f66c30b (diff) | |
| download | linux-d5963d87bf84060ff3fb572bf6d3606f7fd087d1.tar.gz linux-d5963d87bf84060ff3fb572bf6d3606f7fd087d1.tar.bz2 linux-d5963d87bf84060ff3fb572bf6d3606f7fd087d1.zip | |
Merge tag 'v5.1-rc7' into x86/mm, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'fs/cifs/misc.c')
| -rw-r--r-- | fs/cifs/misc.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index 1e1626a2cfc3..0dc6f08020ac 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c @@ -789,6 +789,11 @@ cifs_aio_ctx_alloc(void) { struct cifs_aio_ctx *ctx; + /* + * Must use kzalloc to initialize ctx->bv to NULL and ctx->direct_io + * to false so that we know when we have to unreference pages within + * cifs_aio_ctx_release() + */ ctx = kzalloc(sizeof(struct cifs_aio_ctx), GFP_KERNEL); if (!ctx) return NULL; @@ -807,7 +812,23 @@ cifs_aio_ctx_release(struct kref *refcount) struct cifs_aio_ctx, refcount); cifsFileInfo_put(ctx->cfile); - kvfree(ctx->bv); + + /* + * ctx->bv is only set if setup_aio_ctx_iter() was call successfuly + * which means that iov_iter_get_pages() was a success and thus that + * we have taken reference on pages. + */ + if (ctx->bv) { + unsigned i; + + for (i = 0; i < ctx->npages; i++) { + if (ctx->should_dirty) + set_page_dirty(ctx->bv[i].bv_page); + put_page(ctx->bv[i].bv_page); + } + kvfree(ctx->bv); + } + kfree(ctx); } |
