Skip to content

Commit

Permalink
[media] rc: Set rdev before irq setup
Browse files Browse the repository at this point in the history
This fixes a problem in fintek-cir and nuvoton-cir where the
irq handler would trigger during module load before the rdev member was
set, causing a NULL pointer crash.
It seems this crash is very reproducible (just bombard the receiver with
IR signals during module load), probably because when request_irq is
called, any pending intterupt is handled immediately, before
request_irq returns and rdev can be set.
This same crash was supposed to be fixed by commit
9ef449c ("[media] rc: Postpone ISR
registration"), but the crash was still observed on the nuvoton-cir
driver.
This commit was tested on nuvoton-cir only.

Cc: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Matthijs Kooijman authored and Mauro Carvalho Chehab committed Dec 21, 2012
1 parent 70ef699 commit d62b681
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion drivers/media/rc/fintek-cir.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,8 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
/* rx resolution is hardwired to 50us atm, 1, 25, 100 also possible */
rdev->rx_resolution = US_TO_NS(CIR_SAMPLE_PERIOD);

fintek->rdev = rdev;

ret = -EBUSY;
/* now claim resources */
if (!request_region(fintek->cir_addr,
Expand All @@ -572,7 +574,7 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
goto exit_free_irq;

device_init_wakeup(&pdev->dev, true);
fintek->rdev = rdev;

fit_pr(KERN_NOTICE, "driver has been successfully loaded\n");
if (debug)
cir_dump_regs(fintek);
Expand Down
3 changes: 2 additions & 1 deletion drivers/media/rc/nuvoton-cir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
/* tx bits */
rdev->tx_resolution = XYZ;
#endif
nvt->rdev = rdev;

ret = -EBUSY;
/* now claim resources */
Expand All @@ -1089,7 +1090,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
goto exit_free_wake_irq;

device_init_wakeup(&pdev->dev, true);
nvt->rdev = rdev;

nvt_pr(KERN_NOTICE, "driver has been successfully loaded\n");
if (debug) {
cir_dump_regs(nvt);
Expand Down

0 comments on commit d62b681

Please sign in to comment.