media: rc: ir-hix5hd2: set up device data before requesting the IRQ
Subsystems (3)
PATCH 1/1 media: rc: ir-hix5hd2: set up device data before requesting the IRQ
The hix5hd2 IR interrupt handler passes priv->rdev to the ir_raw_event_*() helpers, which dereference it immediately, and devm_request_irq() unmasks the line as soon as it is called, so the handler can run before probe() returns.
hix5hd2_ir_probe() has requested the IRQ before assigning priv->rdev since the driver was introduced, so an interrupt already pending when the line is requested, e.g. decoded symbols left by the boot firmware, would pass a NULL rc_dev to ir_raw_event_store().
On Hi3716CV200 the handler ran 8 ms after the device was bound and took a NULL-pointer fault in ir_raw_event_store() from interrupt context; on Hi3798MV200H the same fault killed every boot 25 s into startup.
Request the IRQ only after the device data is set up.
The same ordering was fixed for talitos in commit 666d66df2525 ("crypto:
talitos - init tasklets before requesting IRQs") and for bgmac in commit ac1f6e58cb77 ("net: bgmac: enable interrupts only after NAPI is ready").
--- drivers/media/rc/ir-hix5hd2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/rc/ir-hix5hd2.c +4 -4
@@ -316,6 +316,10 @@ static int hix5hd2_ir_probe(struct platform_device *pdev)if (ret <0 ) goto clkerr; + priv->rdev = rdev; + priv->dev = dev; +platform_set_drvdata (pdev, priv); +if (devm_request_irq (dev, priv->irq, hix5hd2_ir_rx_interrupt,0 , pdev->name, priv) <0 ) {dev_err (dev,"IRQ %d register failed\n" , priv->irq);
@@ -323,10 +327,6 @@ static int hix5hd2_ir_probe(struct platform_device *pdev) goto regerr; } - priv->rdev = rdev; - priv->dev = dev; -platform_set_drvdata (pdev, priv); -return ret; regerr:
Signature · 1 line
2.53.0