Skip to content

Commit bdbb4a2

Browse files
groeckWim Van Sebroeck
authored andcommitted
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: 535d178 ("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>
1 parent f777d11 commit bdbb4a2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/watchdog/intel_oc_wdt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
struct intel_oc_wdt {
4242
struct watchdog_device wdd;
4343
struct resource *ctrl_res;
44+
struct watchdog_info info;
4445
bool locked;
4546
};
4647

@@ -115,7 +116,6 @@ static const struct watchdog_ops intel_oc_wdt_ops = {
115116

116117
static int intel_oc_wdt_setup(struct intel_oc_wdt *oc_wdt)
117118
{
118-
struct watchdog_info *info;
119119
unsigned long val;
120120

121121
val = inl(INTEL_OC_WDT_CTRL_REG(oc_wdt));
@@ -134,7 +134,6 @@ static int intel_oc_wdt_setup(struct intel_oc_wdt *oc_wdt)
134134
set_bit(WDOG_HW_RUNNING, &oc_wdt->wdd.status);
135135

136136
if (oc_wdt->locked) {
137-
info = (struct watchdog_info *)&intel_oc_wdt_info;
138137
/*
139138
* Set nowayout unconditionally as we cannot stop
140139
* the watchdog.
@@ -145,7 +144,7 @@ static int intel_oc_wdt_setup(struct intel_oc_wdt *oc_wdt)
145144
* and inform the core we can't change it.
146145
*/
147146
oc_wdt->wdd.timeout = (val & INTEL_OC_WDT_TOV) + 1;
148-
info->options &= ~WDIOF_SETTIMEOUT;
147+
oc_wdt->info.options &= ~WDIOF_SETTIMEOUT;
149148

150149
dev_info(oc_wdt->wdd.parent,
151150
"Register access locked, heartbeat fixed at: %u s\n",
@@ -193,7 +192,8 @@ static int intel_oc_wdt_probe(struct platform_device *pdev)
193192
wdd->min_timeout = INTEL_OC_WDT_MIN_TOV;
194193
wdd->max_timeout = INTEL_OC_WDT_MAX_TOV;
195194
wdd->timeout = INTEL_OC_WDT_DEF_TOV;
196-
wdd->info = &intel_oc_wdt_info;
195+
oc_wdt->info = intel_oc_wdt_info;
196+
wdd->info = &oc_wdt->info;
197197
wdd->ops = &intel_oc_wdt_ops;
198198
wdd->parent = dev;
199199

0 commit comments

Comments
 (0)