[RHEL7,COMMIT] fs/fuse kio_pcs: fix NULL pointer dereference in pcs_mapping_truncate()

Submitted by Konstantin Khorenko on Oct. 29, 2018, 8:51 a.m.

Details

Message ID 201810290851.w9T8pudc031935@finist-ce7.sw.ru
State New
Series "fs/fuse kio_pcs: fix NULL pointer dereference in pcs_mapping_truncate()"
Headers show

Commit Message

Konstantin Khorenko Oct. 29, 2018, 8:51 a.m.
The commit is pushed to "branch-rh7-3.10.0-862.14.4.vz7.72.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.14.4.vz7.72.14
------>
commit dfeff3324b9507fb13c4857fa4b8ab4e04efc883
Author: Pavel Butsykin <pbutsykin@virtuozzo.com>
Date:   Mon Oct 29 11:51:56 2018 +0300

    fs/fuse kio_pcs: fix NULL pointer dereference in pcs_mapping_truncate()
    
    Looks like a logical mistake.
    
    Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_map.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/kio/pcs/pcs_map.c b/fs/fuse/kio/pcs/pcs_map.c
index 4b5462aafe92..25c0281d5278 100644
--- a/fs/fuse/kio/pcs/pcs_map.c
+++ b/fs/fuse/kio/pcs/pcs_map.c
@@ -2494,11 +2494,12 @@  noinline void pcs_mapping_truncate(struct pcs_int_request *ireq, u64 old_size)
 
 	if (m == NULL)
 		queue = 1;
-
-	spin_lock(&m->lock);
-	if (valid_for_truncate(m, ireq))
-		queue = 1;
-	spin_unlock(&m->lock);
+	else {
+		spin_lock(&m->lock);
+		if (valid_for_truncate(m, ireq))
+			queue = 1;
+		spin_unlock(&m->lock);
+	}
 
 	if (queue) {
 		if (m) {