• Alexey Khoroshilov's avatar
    [media] dvb-usb: fix error handling in ttusb_dec_probe() · cf732b5f
    Alexey Khoroshilov authored
    There is an asymmetry in ttusb_dec_init_usb()-ttusb_init_rc()
    and ttusb_dec_exit_usb()-ttusb_dec_exit_rc() in terms of resources
    allocated-deallocated. irq_urb and irq_buffer are allocated in
    ttusb_dec_init_usb(), while they are deallocated in ttusb_dec_exit_rc().
    As a result there is a leak of them in ttusb_dec_probe().
    The patch fixes the asymmetry and a leak on a failure path in ttusb_dec_init_usb().
    By the way, it
    - removes usage of -1 as a custom error code,
    - replaces GFP_ATOMIC by GFP_KERNEL in usb_alloc_coherent() in ttusb_dec_init_usb()
      as soon as all other memory allocation done with GFP_KERNEL;
    - refactors ttusb_dec_boot_dsp() in an equivalent way except for returning 0
      instead of 1 if ttusb_dec_boot_dsp() succeed in (!mode) branch.
    Found by Linux Driver Verification project (linuxtesting.org).
    Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
    Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
    Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
    cf732b5f
ttusb_dec.c 40.1 KB