Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] media: cec: cec_notifier loses no-EDID state and calls 
cec_s_phys_addr() on adap register
--

commit bae9e1de47a9aeb702b139c748d1a200e761edc7
Author: Hans Verkuil <[email protected]>

media: cec: core: improve cec_notifier_phys_addr_invalidate

This commit moves cec_notifier_phys_addr_invalidate() into cec-notifier.c
and changes it to call cec_phys_addr_invalidate() instead of
cec_notifier_set_phys_addr() so the CEC framework knows when no EDID is
present.

> diff --git a/drivers/media/cec/core/cec-notifier.c 
> b/drivers/media/cec/core/cec-notifier.c
> index 8cf1474d0361c..2814ef7d48045 100644
> --- a/drivers/media/cec/core/cec-notifier.c
> +++ b/drivers/media/cec/core/cec-notifier.c
> @@ -216,6 +216,19 @@ void cec_notifier_set_phys_addr_from_edid(struct 
> cec_notifier *n,
>  }
>  EXPORT_SYMBOL_GPL(cec_notifier_set_phys_addr_from_edid);
>  
> +void cec_notifier_phys_addr_invalidate(struct cec_notifier *n)
> +{
> +     if (!n)
> +             return;
> +
> +     mutex_lock(&n->lock);
> +     n->phys_addr = CEC_PHYS_ADDR_INVALID;
> +     if (n->cec_adap && !n->cec_adap->adap_controls_phys_addr)
> +             cec_phys_addr_invalidate(n->cec_adap);
> +     mutex_unlock(&n->lock);
> +}
> +EXPORT_SYMBOL_GPL(cec_notifier_phys_addr_invalidate);

[Severity: Medium]
What happens if cec_notifier_conn_register() or
cec_notifier_phys_addr_invalidate() is called before the CEC adapter
registers via cec_notifier_cec_adap_register()?

When n->cec_adap is NULL, cec_notifier_phys_addr_invalidate() only sets
n->phys_addr = CEC_PHYS_ADDR_INVALID, because struct cec_notifier does not
track whether an EDID is present. This leaves the notifier state
indistinguishable from cec_notifier_set_phys_addr(n, CEC_PHYS_ADDR_INVALID).

When the CEC adapter subsequently registers in
cec_notifier_cec_adap_register(), it unconditionally calls
cec_s_phys_addr() with n->phys_addr:

drivers/media/cec/core/cec-notifier.c:cec_notifier_cec_adap_register() {
        ...
        mutex_lock(&n->lock);
        n->cec_adap = adap;
        adap->conn_info = n->conn_info;
        adap->notifier = n;
        if (!adap->adap_controls_phys_addr)
                cec_s_phys_addr(adap, n->phys_addr, false);
        mutex_unlock(&n->lock);
        ...
}

Doesn't calling cec_s_phys_addr(adap, CEC_PHYS_ADDR_INVALID, false) instead
of cec_phys_addr_invalidate(adap) tell the CEC framework that an EDID is
present (with physical address f.f.f.f) even when no sink is connected at
registration time?

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=6

Reply via email to