NFSD: Decrease nfsd_users in nfsd_startup_generic fail
authorKinglong Mee <kinglongmee@gmail.com>
Wed, 30 Jul 2014 13:26:05 +0000 (21:26 +0800)
committerJ. Bruce Fields <bfields@redhat.com>
Fri, 1 Aug 2014 20:26:09 +0000 (16:26 -0400)
A memory allocation failure could cause nfsd_startup_generic to fail, in
which case nfsd_users wouldn't be incorrectly left elevated.

After nfsd restarts nfsd_startup_generic will then succeed without doing
anything--the first consequence is likely nfs4_start_net finding a bad
laundry_wq and crashing.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Fixes: 4539f14981ce "nfsd: replace boolean nfsd_up flag by users counter"
Cc: stable@vger.kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfssvc.c

index 5d026dca00caebdc6f150fc4aa90095974ffad80..752d56bbe0ba47cda7ed87cb724130944879d269 100644 (file)
@@ -221,7 +221,8 @@ static int nfsd_startup_generic(int nrservs)
         */
        ret = nfsd_racache_init(2*nrservs);
        if (ret)
-               return ret;
+               goto dec_users;
+
        ret = nfs4_state_start();
        if (ret)
                goto out_racache;
@@ -229,6 +230,8 @@ static int nfsd_startup_generic(int nrservs)
 
 out_racache:
        nfsd_racache_shutdown();
+dec_users:
+       nfsd_users--;
        return ret;
 }