Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1013742pxb; Thu, 9 Sep 2021 18:01:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyosggpwf6IFGaLvZE8rx/W4OgtQSLC4yMnB86orOKmm9xD1bcakIpZ/unaabEu3yczICfS X-Received: by 2002:a92:c5c2:: with SMTP id s2mr4497118ilt.278.1631235680189; Thu, 09 Sep 2021 18:01:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631235680; cv=none; d=google.com; s=arc-20160816; b=qM0y2C449LIoD++iES4aWoF0/sCPla+SGm3zN9r5nhIKz1RkxPRdhWMI6bt0go6BJg kUwLwPJJQ+QJCWZRmH83Oc7IAGbAVvf0QRLT7FzQXINyR+vkNNGJXiudtBQvYLsN3mYJ ra/LilUI2xSCeYdb8VN6qpVuaJbl4ABcF1AmnSGCkTBSapuWLaGLTXzyTYSS2fw4vlLd xL3LwFg5gMSnjL3jDrdzD8NwqsoIeZFMnJTHaMsGkLQ3pfVSOVLcF/c8d9kUj65KXNRr p6Yqa21ImGxLtz4SFnvB7z6U6h/Cky8EvQg80q+yoX3yMkBsOpILnc3I5yaqDUiflUKz +3wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dcFfmKSL8410B0HlRE6hHgGKIV6tfijDxVppgGE5NEM=; b=xO/DW6pzhO6lbWBBAVhY+N7i6U0A6AqMLFc0dcDljr/gdPirT4kkkoXhi8aMwa4iHh LfwHAm4JQvFLT+F9SF9EFwryobqSC4cqKonEdX/h+LMdvAc8e7YR+XyJ4yIxJT4zf2HL +/PtN/qTZ9QW69m9w/lZKC6mruQOq1x4uRj3spIKvyHSob6Z7zyM+U0eWad/By2NKU5a txvzi96Z6M0XeY7X/oHEtMD5I122f5qz2QcuVqq5z2CZP+85sCdzZims4MXv0+Uz37PR gfD2JFDyK8R3XPBfGq7FapUnpTtECOj0OeBZoGmx7ytvnVmR8RyQLUoBRbTc0N97sqQc WF6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q+HWPYDj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 189si3696523ioa.35.2021.09.09.18.01.08; Thu, 09 Sep 2021 18:01:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q+HWPYDj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232835AbhIJBBe (ORCPT + 99 others); Thu, 9 Sep 2021 21:01:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:49062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234567AbhIJAXl (ORCPT ); Thu, 9 Sep 2021 20:23:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C037560FC0; Fri, 10 Sep 2021 00:22:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631233351; bh=FyZy43GHK7jIYNL7e0FXP+TeGrf6xbmOHOWhZy9F/FA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q+HWPYDjTuZQBwPvzd3STghCJi4xQGwgea6tCT0Drp5CaiNrK5Qv/Gznagpz7p2Og Iyuruoxb1SmLA/FTCt0LuVfA0h4XuU4LSsbH83UXU4WcDrURFHEXoLXSGCcYTXp+Qj Em859NhAJtDYv2GU1hecLMX+Ckcs12pHmIvCQ4qGieCyVXIjeFkAP7agHQIrwlEreO MVG68iGAqK8jtvO4prHqL7zQ5xlZEr/miJoAMXRnb2Jm5g1QVpN7e/HVIiZcp+UHX5 iPNIoH1Q4KxlnT9mnNpbvZ2wD7pxTJyIsc3wAOsVY2pYP6n/JUI4KJ0taPNYeN0xeu S0nPbbXOQbAXQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tuo Li , TOTE Robot , Joseph Qi , Mark Fasheh , Joel Becker , Junxiao Bi , Changwei Ge , Gang He , Jun Piao , Andrew Morton , Linus Torvalds , Sasha Levin , ocfs2-devel@oss.oracle.com Subject: [PATCH AUTOSEL 5.4 36/37] ocfs2: quota_local: fix possible uninitialized-variable access in ocfs2_local_read_info() Date: Thu, 9 Sep 2021 20:21:41 -0400 Message-Id: <20210910002143.175731-36-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210910002143.175731-1-sashal@kernel.org> References: <20210910002143.175731-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tuo Li [ Upstream commit 6c85c2c728193d19d6a908ae9fb312d0325e65ca ] A memory block is allocated through kmalloc(), and its return value is assigned to the pointer oinfo. However, oinfo->dqi_gqinode is not initialized but it is accessed in: iput(oinfo->dqi_gqinode); To fix this possible uninitialized-variable access, assign NULL to oinfo->dqi_gqinode, and add ocfs2_qinfo_lock_res_init() behind the assignment in ocfs2_local_read_info(). Remove ocfs2_qinfo_lock_res_init() in ocfs2_global_read_info(). Link: https://lkml.kernel.org/r/20210804031832.57154-1-islituo@gmail.com Signed-off-by: Tuo Li Reported-by: TOTE Robot Reviewed-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Gang He Cc: Jun Piao Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/ocfs2/quota_global.c | 1 - fs/ocfs2/quota_local.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c index eda83487c9ec..f033de733adb 100644 --- a/fs/ocfs2/quota_global.c +++ b/fs/ocfs2/quota_global.c @@ -357,7 +357,6 @@ int ocfs2_global_read_info(struct super_block *sb, int type) } oinfo->dqi_gi.dqi_sb = sb; oinfo->dqi_gi.dqi_type = type; - ocfs2_qinfo_lock_res_init(&oinfo->dqi_gqlock, oinfo); oinfo->dqi_gi.dqi_entry_size = sizeof(struct ocfs2_global_disk_dqblk); oinfo->dqi_gi.dqi_ops = &ocfs2_global_ops; oinfo->dqi_gqi_bh = NULL; diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c index b1a8b046f4c2..0e4b16d4c037 100644 --- a/fs/ocfs2/quota_local.c +++ b/fs/ocfs2/quota_local.c @@ -702,6 +702,8 @@ static int ocfs2_local_read_info(struct super_block *sb, int type) info->dqi_priv = oinfo; oinfo->dqi_type = type; INIT_LIST_HEAD(&oinfo->dqi_chunk); + oinfo->dqi_gqinode = NULL; + ocfs2_qinfo_lock_res_init(&oinfo->dqi_gqlock, oinfo); oinfo->dqi_rec = NULL; oinfo->dqi_lqi_bh = NULL; oinfo->dqi_libh = NULL; -- 2.30.2