[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181128224234.22998-1-babu.moger@amd.com>
Date: Wed, 28 Nov 2018 22:42:47 +0000
From: "Moger, Babu" <Babu.Moger@....com>
To: "tglx@...utronix.de" <tglx@...utronix.de>,
"mingo@...hat.com" <mingo@...hat.com>,
"bp@...en8.de" <bp@...en8.de>
CC: "hpa@...or.com" <hpa@...or.com>, "x86@...nel.org" <x86@...nel.org>,
"fenghua.yu@...el.com" <fenghua.yu@...el.com>,
"reinette.chatre@...el.com" <reinette.chatre@...el.com>,
"Moger, Babu" <Babu.Moger@....com>,
"dan.carpenter@...cle.com" <dan.carpenter@...cle.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH v3] x86/resctrl: Remove unnecessary check for cbm_validate
The static checker(smatch) reports the following error after the
commit a36c5ff560fb ("x86/resctrl: Bring cbm_validate() into the
resource structure").
arch/x86/kernel/cpu/resctrl//ctrlmondata.c:227 parse_cbm()
error: uninitialized symbol 'cbm_val'.
arch/x86/kernel/cpu/resctrl//ctrlmondata.c:236 parse_cbm()
error: uninitialized symbol 'cbm_val'.
This could happen from the following condition if r->cbm_validate is
NULL which could leave cbm_val uninitialized.
if (r->cbm_validate && !r->cbm_validate(data->buf, &cbm_val, r))
Looking at the code again, there is no case where r->cbm_validate can be
NULL. cbm_validate is initialized based on the vendor check. It is either
Intel or AMD. In both the cases it is initialized properly. Remove the
first check completely.
Verified the fix running Smatch.
Fixes: a36c5ff560fb ("x86/resctrl: Bring cbm_validate() into the resource structure")
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
Signed-off-by: Babu Moger <babu.moger@....com>
---
v2->v3:
Removed the unnecessary and added detailed explaination.
v1->v2:
Added more details.
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index 03ee13235a45..ba11f54f5ab8 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -219,7 +219,7 @@ int parse_cbm(struct rdt_parse_data *data, struct rdt_resource *r,
return -EINVAL;
}
- if (r->cbm_validate && !r->cbm_validate(data->buf, &cbm_val, r))
+ if (!r->cbm_validate(data->buf, &cbm_val, r))
return -EINVAL;
if ((rdtgrp->mode == RDT_MODE_EXCLUSIVE ||
--
2.17.1
Powered by blists - more mailing lists