Commit e62f89f2aebd57f48687f139c20cf6375693b622

Authored by David Woodhouse
Committed by David Woodhouse
1 parent bc179153ae

cxusb: treat firmware data as const

...which means allocating our own copy when we want to modify it.

(stupid thinko fixed by mkrufky)

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>

Showing 1 changed file with 18 additions and 3 deletions Side-by-side Diff

drivers/media/dvb/dvb-usb/cxusb.c
... ... @@ -24,6 +24,7 @@
24 24 * see Documentation/dvb/README.dvb-usb for more information
25 25 */
26 26 #include <media/tuner.h>
  27 +#include <linux/vmalloc.h>
27 28  
28 29 #include "cxusb.h"
29 30  
30 31  
31 32  
... ... @@ -700,12 +701,26 @@
700 701  
701 702 if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
702 703 fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
703   - fw->data[idoff + 2] =
  704 + struct firmware new_fw;
  705 + u8 *new_fw_data = vmalloc(fw->size);
  706 + int ret;
  707 +
  708 + if (!new_fw_data)
  709 + return -ENOMEM;
  710 +
  711 + memcpy(new_fw_data, fw->data, fw->size);
  712 + new_fw.size = fw->size;
  713 + new_fw.data = new_fw_data;
  714 +
  715 + new_fw_data[idoff + 2] =
704 716 le16_to_cpu(udev->descriptor.idProduct) + 1;
705   - fw->data[idoff + 3] =
  717 + new_fw_data[idoff + 3] =
706 718 le16_to_cpu(udev->descriptor.idProduct) >> 8;
707 719  
708   - return usb_cypress_load_firmware(udev, fw, CYPRESS_FX2);
  720 + ret = usb_cypress_load_firmware(udev, &new_fw,
  721 + CYPRESS_FX2);
  722 + vfree(new_fw_data);
  723 + return ret;
709 724 }
710 725 }
711 726