Whamcloud - gitweb
LU-2504 procfs: Call put_cpu() if stats alloc fails
authorJohn L. Hammond <jhammond@tacc.utexas.edu>
Mon, 17 Dec 2012 23:34:57 +0000 (17:34 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 8 Jan 2013 05:31:12 +0000 (00:31 -0500)
Call put_cpu() if lprocfs_stats_alloc_one() fails in
lprocfs_stats_lock().

Signed-off-by: John L. Hammond <jhammond@tacc.utexas.edu>
Change-Id: I12c3eb9ecbbef3086493d63c300ddb853d86dd98
Reviewed-on: http://review.whamcloud.com/4845
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lprocfs_status.h

index 1c2b906..030df3f 100644 (file)
@@ -389,9 +389,15 @@ static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int opc,
                if ((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0) {
                        cpuid = cfs_get_cpu();
 
                if ((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0) {
                        cpuid = cfs_get_cpu();
 
-                       if (unlikely(stats->ls_percpu[cpuid + 1] == NULL))
+                       if (unlikely(stats->ls_percpu[cpuid + 1] == NULL)) {
                                rc = lprocfs_stats_alloc_one(stats, cpuid + 1);
                                rc = lprocfs_stats_alloc_one(stats, cpuid + 1);
-                       return rc < 0 ? rc : cpuid + 1;
+                               if (rc < 0) {
+                                       cfs_put_cpu();
+                                       return rc;
+                               }
+                       }
+
+                       return cpuid + 1;
                }
 
                /* non-percpu counter stats */
                }
 
                /* non-percpu counter stats */