From: John L. Hammond Date: Mon, 17 Dec 2012 23:34:57 +0000 (-0600) Subject: LU-2504 procfs: Call put_cpu() if stats alloc fails X-Git-Tag: 2.3.59~57 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=3857faaaa1dfe89f903c9a3e1f35eba32595801d LU-2504 procfs: Call put_cpu() if stats alloc fails Call put_cpu() if lprocfs_stats_alloc_one() fails in lprocfs_stats_lock(). Signed-off-by: John L. Hammond Change-Id: I12c3eb9ecbbef3086493d63c300ddb853d86dd98 Reviewed-on: http://review.whamcloud.com/4845 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Keith Mannthey Reviewed-by: Bob Glossman Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index 1c2b906..030df3f 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -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 (unlikely(stats->ls_percpu[cpuid + 1] == NULL)) + if (unlikely(stats->ls_percpu[cpuid + 1] == NULL)) { 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 */