Whamcloud - gitweb
Branch b_release_1_4_6
authoradilger <adilger>
Sat, 21 Jan 2006 00:53:46 +0000 (00:53 +0000)
committeradilger <adilger>
Sat, 21 Jan 2006 00:53:46 +0000 (00:53 +0000)
Fix memory leak found by Coverity - we were not freeing any of the
other allocated structs if there was a later allocation error.

lustre/lov/lov_qos.c

index a39540f..bde768b 100644 (file)
@@ -165,12 +165,17 @@ int qos_prep_create(struct lov_obd *lov, struct lov_request_set *set, int newea)
 
                 req->rq_buflen = sizeof(*req->rq_md);
                 OBD_ALLOC(req->rq_md, req->rq_buflen);
-                if (req->rq_md == NULL)
+                if (req->rq_md == NULL) {
+                        OBD_FREE_PTR(req);
                         GOTO(out, rc = -ENOMEM);
+                }
 
                 req->rq_oa = obdo_alloc();
-                if (req->rq_oa == NULL)
+                if (req->rq_oa == NULL) {
+                        OBD_FREE_PTR(req->rq_md);
+                        OBD_FREE_PTR(req);
                         GOTO(out, rc = -ENOMEM);
+                }
 
                 req->rq_idx = ost_idx;
                 req->rq_stripe = i;
@@ -217,5 +222,6 @@ int qos_prep_create(struct lov_obd *lov, struct lov_request_set *set, int newea)
                 rc = 0;
         }
 out:
+
         RETURN(rc);
 }