diff mbox series

[v3,3/3] ceph: fix possible kunmaping random vaddr

Message ID 20220412070745.22795-4-xiubli@redhat.com
State New
Headers show
Series ceph: misc fix size truncate for fscrypt | expand

Commit Message

Xiubo Li April 12, 2022, 7:07 a.m. UTC
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 fs/ceph/inode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 1c775a365b5e..83f18b058d8c 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -2253,7 +2253,7 @@  static int fill_fscrypt_truncate(struct inode *inode,
 	loff_t pos, orig_pos = round_down(attr->ia_size, CEPH_FSCRYPT_BLOCK_SIZE);
 	u64 block = orig_pos >> CEPH_FSCRYPT_BLOCK_SHIFT;
 	struct ceph_pagelist *pagelist = NULL;
-	struct kvec iov;
+	struct kvec iov = {0};
 	struct iov_iter iter;
 	struct page *page = NULL;
 	struct ceph_fscrypt_truncate_size_header header;
@@ -2364,7 +2364,8 @@  static int fill_fscrypt_truncate(struct inode *inode,
 	dout("%s %p size dropping cap refs on %s\n", __func__,
 	     inode, ceph_cap_string(got));
 	ceph_put_cap_refs(ci, got);
-	kunmap_local(iov.iov_base);
+	if (iov.iov_base)
+		kunmap_local(iov.iov_base);
 	if (page)
 		__free_pages(page, 0);
 	if (ret && pagelist)