Skip to content

Commit 9f6be2b

Browse files
tkhaimchehab
authored andcommitted
[media] s2255: Do not free fw_data until timer handler has actually stopped using it
Function del_timer() does not guarantee that timer was really deleted. If the timer handler is beeing executed at the moment, the function does nothing. So, we have a race between del_timer() and kfree(), and it's possible to use already freed memory in the handler. Signed-off-by: Kirill Tkhai <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent cd6ff5c commit 9f6be2b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/media/usb/s2255/s2255drv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ static void s2255_destroy(struct s2255_dev *dev)
15211521
/* board shutdown stops the read pipe if it is running */
15221522
s2255_board_shutdown(dev);
15231523
/* make sure firmware still not trying to load */
1524-
del_timer(&dev->timer); /* only started in .probe and .open */
1524+
del_timer_sync(&dev->timer); /* only started in .probe and .open */
15251525
if (dev->fw_data->fw_urb) {
15261526
usb_kill_urb(dev->fw_data->fw_urb);
15271527
usb_free_urb(dev->fw_data->fw_urb);
@@ -2351,7 +2351,7 @@ static int s2255_probe(struct usb_interface *interface,
23512351
errorFWDATA2:
23522352
usb_free_urb(dev->fw_data->fw_urb);
23532353
errorFWURB:
2354-
del_timer(&dev->timer);
2354+
del_timer_sync(&dev->timer);
23552355
errorEP:
23562356
usb_put_dev(dev->udev);
23572357
errorUDEV:

0 commit comments

Comments
 (0)