Re: [PATCH v2] watchdog: qcom: Propagate errors from optional IRQ lookup
Bui Duc Phuc <[email protected]>
| Newsgroups | org.kernel.vger.linux-watchdog,dev.linux.lists.sashiko-reviews |
|---|---|
| Message-ID | <CAABR9nE=oRUr1XbStf0ztudQ9HM7LEVc_fVcmN7QkQixi4DyYw@mail.gmail.com> |
> [Severity: High]
> Does this code leave wdt->wdd.info uninitialized if data->pretimeout is true
> but the optional IRQ is missing?
>
> If platform_get_irq_optional() returns -ENXIO, the if (irq > 0) branch is
> skipped. Since this all occurs inside the if (data->pretimeout) branch, the
> outer else block is bypassed.
>
> Could this cause devm_watchdog_register_device() to later fail with -EINVAL
> because wdd->info is NULL?
>
> > } else {
> > - if (irq == -EPROBE_DEFER)
> > - return -EPROBE_DEFER;
> > -
> > wdt->wdd.info = &qcom_wdt_info;
> > }
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Oh, it looks like this approach is correct.
Option C (default-then-override, only look up the IRQ when pretimeout
is supported):
----------------------
wdt->wdd.info = &qcom_wdt_info;
if (data->pretimeout) {
irq = platform_get_irq_optional(pdev, 0);
if(irq < 0 && irq != -ENXIO)
return irq;
if (irq > 0){
ret = devm_request_irq(dev, irq, qcom_wdt_isr, 0,
"wdt_bark", &wdt->wdd);
if(ret)
return ret;
wdt->wdd.info= &qcom_wdt_pt_info;
wdt->wdd.pretimeout = 1;
}
}
-----------------------