Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: intel_oc_wdt: Do not try to write into const memory

The code tries to update the intel_oc_wdt_info data structure if the
watchdog is locked. That data structure is marked as const and can not
be written into. Copy it into struct intel_oc_wdt and modify it there
to fix the problem.

Reported-by: Petar Kulić <cooleech@gmail.com>
Cc: Diogo Ivo <diogo.ivo@siemens.com>
Fixes: 535d1784d8a9 ("watchdog: Add driver for Intel OC WDT")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Diogo Ivo <diogo.ivo@siemens.com>
Tested-by: Diogo Ivo <diogo.ivo@siemens.com>
Link: https://lore.kernel.org/linux-watchdog/20250818031838.3359-1-diogo.ivo@tecnico.ulisboa.pt/T/#t
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>

authored by

Guenter Roeck and committed by
Wim Van Sebroeck
bdbb4a2d f777d111

+4 -4
+4 -4
drivers/watchdog/intel_oc_wdt.c
··· 41 41 struct intel_oc_wdt { 42 42 struct watchdog_device wdd; 43 43 struct resource *ctrl_res; 44 + struct watchdog_info info; 44 45 bool locked; 45 46 }; 46 47 ··· 116 115 117 116 static int intel_oc_wdt_setup(struct intel_oc_wdt *oc_wdt) 118 117 { 119 - struct watchdog_info *info; 120 118 unsigned long val; 121 119 122 120 val = inl(INTEL_OC_WDT_CTRL_REG(oc_wdt)); ··· 134 134 set_bit(WDOG_HW_RUNNING, &oc_wdt->wdd.status); 135 135 136 136 if (oc_wdt->locked) { 137 - info = (struct watchdog_info *)&intel_oc_wdt_info; 138 137 /* 139 138 * Set nowayout unconditionally as we cannot stop 140 139 * the watchdog. ··· 144 145 * and inform the core we can't change it. 145 146 */ 146 147 oc_wdt->wdd.timeout = (val & INTEL_OC_WDT_TOV) + 1; 147 - info->options &= ~WDIOF_SETTIMEOUT; 148 + oc_wdt->info.options &= ~WDIOF_SETTIMEOUT; 148 149 149 150 dev_info(oc_wdt->wdd.parent, 150 151 "Register access locked, heartbeat fixed at: %u s\n", ··· 192 193 wdd->min_timeout = INTEL_OC_WDT_MIN_TOV; 193 194 wdd->max_timeout = INTEL_OC_WDT_MAX_TOV; 194 195 wdd->timeout = INTEL_OC_WDT_DEF_TOV; 195 - wdd->info = &intel_oc_wdt_info; 196 + oc_wdt->info = intel_oc_wdt_info; 197 + wdd->info = &oc_wdt->info; 196 198 wdd->ops = &intel_oc_wdt_ops; 197 199 wdd->parent = dev; 198 200