quota: add missing use of dq_data_lock in __dquot_initialize
authorJeff Mahoney <jeffm@suse.com>
Wed, 27 Feb 2013 19:43:09 +0000 (14:43 -0500)
committerJan Kara <jack@suse.cz>
Mon, 11 Mar 2013 21:05:56 +0000 (22:05 +0100)
The bulk of __dquot_initialize runs under the dqptr_sem which
protects the inode->i_dquot pointers. It doesn't protect the
dereferenced contents, though. Those are protected by the
dq_data_lock, which is missing around the dquot_resv_space call.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/quota/dquot.c

index 05ae3c97f7a5fc552e771f9cf7312e4b61cffc1f..3e64169ef52710ff11f9c7f8c44ee3c910cbd321 100644 (file)
@@ -1439,8 +1439,11 @@ static void __dquot_initialize(struct inode *inode, int type)
                         * did a write before quota was turned on
                         */
                        rsv = inode_get_rsv_space(inode);
-                       if (unlikely(rsv))
+                       if (unlikely(rsv)) {
+                               spin_lock(&dq_data_lock);
                                dquot_resv_space(inode->i_dquot[cnt], rsv);
+                               spin_unlock(&dq_data_lock);
+                       }
                }
        }
 out_err: