Skip to content

Commit

Permalink
[media] xc5000: fix memory corruption when unplugging device
Browse files Browse the repository at this point in the history
This patch addresses a regression introduced in the following patch:

commit 5264a52
Author: Shuah Khan <shuahkh@osg.samsung.com>
    [media] media: tuner xc5000 - release firmwware from xc5000_release()

The "priv" struct is actually reference counted, so the xc5000_release()
function gets called multiple times for hybrid devices.  Because
release_firmware() was always being called, it would work fine as expected
on the first call but then the second call would corrupt aribtrary memory.

Set the pointer to NULL after releasing so that we don't call
release_firmware() twice.

This problem was detected in the HVR-950q where plugging/unplugging the
device multiple times would intermittently show panics in completely
unrelated areas of the kernel.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
  • Loading branch information
Devin Heitmueller authored and Mauro Carvalho Chehab committed Apr 8, 2015
1 parent 09bf4a8 commit 856260a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/media/tuners/xc5000.c
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,10 @@ static int xc5000_release(struct dvb_frontend *fe)

if (priv) {
cancel_delayed_work(&priv->timer_sleep);
release_firmware(priv->firmware);
if (priv->firmware) {
release_firmware(priv->firmware);
priv->firmware = NULL;
}
hybrid_tuner_release_state(priv);
}

Expand Down

0 comments on commit 856260a

Please sign in to comment.