[PATCH 4.4 142/210] quota: Fix possible GPF due to uninitialised pointers

From: Greg Kroah-Hartman
Date: Sun Apr 10 2016 - 15:18:38 EST


4.4-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nikolay Borisov <kernel@xxxxxxxx>

commit ab73ef46398e2c0159f3a71de834586422d2a44a upstream.

When dqget() in __dquot_initialize() fails e.g. due to IO error,
__dquot_initialize() will pass an array of uninitialized pointers to
dqput_all() and thus can lead to deference of random data. Fix the
problem by properly initializing the array.

Signed-off-by: Nikolay Borisov <kernel@xxxxxxxx>
Signed-off-by: Jan Kara <jack@xxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
fs/quota/dquot.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1398,7 +1398,7 @@ static int dquot_active(const struct ino
static int __dquot_initialize(struct inode *inode, int type)
{
int cnt, init_needed = 0;
- struct dquot **dquots, *got[MAXQUOTAS];
+ struct dquot **dquots, *got[MAXQUOTAS] = {};
struct super_block *sb = inode->i_sb;
qsize_t rsv;
int ret = 0;
@@ -1415,7 +1415,6 @@ static int __dquot_initialize(struct ino
int rc;
struct dquot *dquot;

- got[cnt] = NULL;
if (type != -1 && cnt != type)
continue;
/*