Commit fc7fe795 authored by Babu Moger's avatar Babu Moger Committed by Wenkuan Wang
Browse files

x86/resctrl: Remove redundant variable in mbm_config_write_domain()

mainline inclusion
from mainline-v6.9-rc1
commit fc747eebef734563cf68a512f57937c8f231834a
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9U2JC


CVE: NA

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

The kernel test robot reported the following warning after commit

  54e35eb8611c ("x86/resctrl: Read supported bandwidth sources from CPUID").

even though the issue is present even in the original commit

  92bd5a13 ("x86/resctrl: Add interface to write mbm_total_bytes_config")

which added this function. The reported warning is:

  $ make C=1 CHECK=scripts/coccicheck arch/x86/kernel/cpu/resctrl/rdtgroup.o
  ...
  arch/x86/kernel/cpu/resctrl/rdtgroup.c:1621:5-8: Unneeded variable: "ret". Return "0" on line 1655

Remove the local variable 'ret'.

  [ bp: Massage commit message, make mbm_config_write_domain() void. ]

Fixes: 92bd5a13 ("x86/resctrl: Add interface to write mbm_total_bytes_config")
Reported-by: default avatarkernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202401241810.jbd8Ipa1-lkp@intel.com/


Signed-off-by: default avatarBabu Moger <babu.moger@amd.com>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Acked-by: default avatarReinette Chatre <reinette.chatre@intel.com>
Link: https://lore.kernel.org/r/202401241810.jbd8Ipa1-lkp@intel.com


Signed-off-by: default avatarWenkuan Wang <Wenkuan.Wang@amd.com>
parent b5d4acae
Loading
Loading
Loading
Loading
+4 −11
Original line number Diff line number Diff line
@@ -1582,11 +1582,10 @@ static void mon_event_config_write(void *info)
	wrmsr(MSR_IA32_EVT_CFG_BASE + index, mon_info->mon_config, 0);
}

static int mbm_config_write_domain(struct rdt_resource *r,
static void mbm_config_write_domain(struct rdt_resource *r,
				    struct rdt_domain *d, u32 evtid, u32 val)
{
	struct mon_config_info mon_info = {0};
	int ret = 0;

	/* mon_config cannot be more than the supported set of events */
	if (val > MAX_EVT_CONFIG_BITS) {
@@ -1601,7 +1600,7 @@ static int mbm_config_write_domain(struct rdt_resource *r,
	mon_info.evtid = evtid;
	mondata_config_read(d, &mon_info);
	if (mon_info.mon_config == val)
		goto out;
		return;

	mon_info.mon_config = val;

@@ -1624,9 +1623,6 @@ static int mbm_config_write_domain(struct rdt_resource *r,
	 * mbm_local and mbm_total counts for all the RMIDs.
	 */
	resctrl_arch_reset_rmid_all(r, d);

out:
	return ret;
}

static int mon_config_write(struct rdt_resource *r, char *tok, u32 evtid)
@@ -1634,7 +1630,6 @@ static int mon_config_write(struct rdt_resource *r, char *tok, u32 evtid)
	char *dom_str = NULL, *id_str;
	unsigned long dom_id, val;
	struct rdt_domain *d;
	int ret = 0;

next:
	if (!tok || tok[0] == '\0')
@@ -1656,9 +1651,7 @@ static int mon_config_write(struct rdt_resource *r, char *tok, u32 evtid)

	list_for_each_entry(d, &r->domains, list) {
		if (d->id == dom_id) {
			ret = mbm_config_write_domain(r, d, evtid, val);
			if (ret)
				return -EINVAL;
			mbm_config_write_domain(r, d, evtid, val);
			goto next;
		}
	}