[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202202011339.oPwRPmNf-lkp@intel.com>
Date: Tue, 1 Feb 2022 10:18:15 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: kbuild@...ts.01.org, Emmanuel Gil Peyrot <linkmauve@...kmauve.fr>
Cc: lkp@...el.com, kbuild-all@...ts.01.org,
linux-kernel@...r.kernel.org,
Alexandre Belloni <alexandre.belloni@...tlin.com>
Subject: drivers/rtc/rtc-gamecube.c:247 gamecube_rtc_read_offset_from_sram()
warn: 'hw_srnprot' not released on lines: 239.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 26291c54e111ff6ba87a164d85d4a4e134b7315c
commit: 86559400b3ef9de93ba50523cffe767c35cd531a rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U
config: nios2-randconfig-m031-20220131 (https://download.01.org/0day-ci/archive/20220201/202202011339.oPwRPmNf-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 11.2.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
smatch warnings:
drivers/rtc/rtc-gamecube.c:247 gamecube_rtc_read_offset_from_sram() warn: 'hw_srnprot' not released on lines: 239.
vim +/hw_srnprot +247 drivers/rtc/rtc-gamecube.c
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 190 static int gamecube_rtc_read_offset_from_sram(struct priv *d)
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 191 {
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 192 struct device_node *np;
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 193 int ret;
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 194 struct resource res;
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 195 void __iomem *hw_srnprot;
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 196 u32 old;
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 197
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 198 np = of_find_compatible_node(NULL, NULL, "nintendo,latte-srnprot");
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 199 if (!np)
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 200 np = of_find_compatible_node(NULL, NULL,
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 201 "nintendo,hollywood-srnprot");
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 202 if (!np) {
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 203 pr_info("HW_SRNPROT not found, assuming a GameCube\n");
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 204 return regmap_read(d->regmap, RTC_SRAM_BIAS, &d->rtc_bias);
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 205 }
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 206
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 207 ret = of_address_to_resource(np, 0, &res);
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 208 if (ret) {
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 209 pr_err("no io memory range found\n");
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 210 return -1;
Need to of_node_put(np);
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 211 }
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 212
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 213 hw_srnprot = ioremap(res.start, resource_size(&res));
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 214 old = ioread32be(hw_srnprot);
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 215
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 216 /* TODO: figure out why we use this magic constant. I obtained it by
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 217 * reading the leftover value after boot, after IOSU already ran.
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 218 *
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 219 * On my Wii U, setting this register to 1 prevents the console from
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 220 * rebooting properly, so wiiubrew.org must be missing something.
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 221 *
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 222 * See https://wiiubrew.org/wiki/Hardware/Latte_registers
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 223 */
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 224 if (old != 0x7bf)
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 225 iowrite32be(0x7bf, hw_srnprot);
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 226
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 227 /* Get the offset from RTC SRAM.
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 228 *
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 229 * Its default location on the GameCube and on the Wii is in the SRAM,
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 230 * while on the Wii U the bootloader needs to fill it with the contents
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 231 * of /config/rtc.xml on the SLC (the eMMC). We don’t do that from
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 232 * Linux since it requires implementing a proprietary filesystem and do
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 233 * file decryption, instead we require the bootloader to fill the same
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 234 * SRAM address as on previous consoles.
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 235 */
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 236 ret = regmap_read(d->regmap, RTC_SRAM_BIAS, &d->rtc_bias);
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 237 if (ret) {
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 238 pr_err("failed to get the RTC bias\n");
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 239 return -1;
No clean up on this error path.
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 240 }
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 241
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 242 /* Reset SRAM access to how it was before, our job here is done. */
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 243 if (old != 0x7bf)
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 244 iowrite32be(old, hw_srnprot);
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 245 iounmap(hw_srnprot);
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 246
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 @247 return 0;
You probably want to of_node_put(np) on the success path as well?
Otherwise if you do more than INT_MAX reads it will crash.
86559400b3ef9d Emmanuel Gil Peyrot 2021-12-15 248 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Powered by blists - more mailing lists