Skip to content

Commit

Permalink
[media] em28xx: fix deadlock when unplugging and replugging a DVB ada…
Browse files Browse the repository at this point in the history
…pter

This fixes the deadlock that occurs with either multiple PCTV 290e adapters or when a single PCTV 290e adapter is replugged.

For DVB devices, the device lock must now *not* be held when adding/removing either a device or an extension to the respective lists. (Because em28xx_init_dvb() will want to take the lock instead).

Conversely, for Audio-Only devices, the device lock *must* be held when adding/removing either a device or an extension to the respective lists.

Signed-off-by: Chris Rankin <rankincj@yahoo.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Chris Rankin authored and Mauro Carvalho Chehab committed Sep 25, 2011
1 parent 4a6c4a9 commit b868a53
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/media/video/em28xx/em28xx-cards.c
Original file line number Diff line number Diff line change
Expand Up @@ -3005,7 +3005,9 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
goto fail;
}

mutex_unlock(&dev->lock);
em28xx_init_extension(dev);
mutex_lock(&dev->lock);

/* Save some power by putting tuner to sleep */
v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 0);
Expand Down Expand Up @@ -3301,10 +3303,10 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
em28xx_release_resources(dev);
}

em28xx_close_extension(dev);

mutex_unlock(&dev->lock);

em28xx_close_extension(dev);

if (!dev->users) {
kfree(dev->alt_max_pkt_size);
kfree(dev);
Expand Down

0 comments on commit b868a53

Please sign in to comment.