From 200ad3adbb5773067a3947efcd9545dbd3694705 Mon Sep 17 00:00:00 2001
From: adilger <adilger>
Date: Tue, 27 Mar 2007 07:11:00 +0000
Subject: [PATCH] Branch HEAD Check handle validity before using it. b=11740
 i=green

---
 lustre/obdfilter/filter.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c
index 9a0ad0f180..779a2153dd 100644
--- a/lustre/obdfilter/filter.c
+++ b/lustre/obdfilter/filter.c
@@ -1222,9 +1222,9 @@ static int filter_prepare_destroy(struct obd_device *obd, obd_id objid)
         ENTRY;
         /* Tell the clients that the object is gone now and that they should
          * throw away any cached pages. */
-        rc = ldlm_cli_enqueue_local(obd->obd_namespace, res_id, LDLM_EXTENT, 
-                                    &policy, LCK_PW, &flags, ldlm_blocking_ast, 
-                                    ldlm_completion_ast, NULL, NULL, 0, NULL, 
+        rc = ldlm_cli_enqueue_local(obd->obd_namespace, res_id, LDLM_EXTENT,
+                                    &policy, LCK_PW, &flags, ldlm_blocking_ast,
+                                    ldlm_completion_ast, NULL, NULL, 0, NULL,
                                     &lockh);
 
         /* We only care about the side-effects, just drop the lock. */
@@ -2378,6 +2378,9 @@ int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
                 handle = fsfilt_start_log(exp->exp_obd, inode,
                                           FSFILT_OP_SETATTR, oti, 1);
 
+                if (IS_ERR(handle))
+                        GOTO(out_unlock, rc = PTR_ERR(handle));
+
                 /* update inode EA only once when inode is suid bit marked. As
                  * on 2.6.x UID and GID may be set separately, we check here
                  * only one of them to avoid double setting. */
@@ -2386,10 +2389,10 @@ int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
         } else {
                 handle = fsfilt_start(exp->exp_obd, inode,
                                       FSFILT_OP_SETATTR, oti);
-        }
 
-        if (IS_ERR(handle))
-                GOTO(out_unlock, rc = PTR_ERR(handle));
+                if (IS_ERR(handle))
+                        GOTO(out_unlock, rc = PTR_ERR(handle));
+        }
 
         if (oa->o_valid & OBD_MD_FLFLAGS) {
                 rc = fsfilt_iocontrol(exp->exp_obd, inode, NULL,
-- 
GitLab