From 29edb81d7ce6ceecb1f012ccebe86d5052a2cf79 Mon Sep 17 00:00:00 2001
From: Roland Fehrenbacher <rf@q-leap.de>
Date: Thu, 20 Mar 2014 13:40:06 +0100
Subject: [PATCH] QL: Lustre - Avoid null pointer dereference in
 mdc_unpack_acl

LU-4787: The acl structure returned by posix_acl_from_xattr in mdc_unpack_acl
can become a null pointer e.g. in the case of data corruption on the MDT.
This will result in a kernel OOPS.
Extend the check on the return value of posix_acl_from_xattr to also include
a null pointer by using IS_ERR_OR_NULL instead of IS_ERR.
---
 drivers/staging/lustre/lustre/mdc/mdc_request.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index ed3a7a0..4e047c0 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -454,7 +454,7 @@ static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
 		return -EPROTO;
 
 	acl = posix_acl_from_xattr(&init_user_ns, buf, body->aclsize);
-	if (IS_ERR(acl)) {
+	if (IS_ERR_OR_NULL(acl)) {
 		rc = PTR_ERR(acl);
 		CERROR("convert xattr to acl: %d\n", rc);
 		return rc;
-- 
1.7.9.5

