diff options
author | Stefan Brüns <stefan.bruens@rwth-aachen.de> | 2017-02-12 10:02:13 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-03-08 20:43:02 -0500 |
commit | 67b0503db9c29b04eadfeede6bebbfe5ddad94ef (patch) | |
tree | cb24c60146b53f22470408185b6c4900a8c52a5c | |
parent | 8c71fff434e5ecf5ff27bd61db1bc9ac4c2b2a1b (diff) |
[media] dvb-usb-firmware: don't do DMA on stack
The buffer allocation for the firmware data was changed in
commit 43fab9793c1f ("[media] dvb-usb: don't use stack for firmware load")
but the same applies for the reset value.
Fixes: 43fab9793c1f ("[media] dvb-usb: don't use stack for firmware load")
Cc: stable@vger.kernel.org
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r-- | drivers/media/usb/dvb-usb/dvb-usb-firmware.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c index ab9866024ec7..04033efe7ad5 100644 --- a/drivers/media/usb/dvb-usb/dvb-usb-firmware.c +++ b/drivers/media/usb/dvb-usb/dvb-usb-firmware.c | |||
@@ -36,16 +36,18 @@ static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 le | |||
36 | int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type) | 36 | int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type) |
37 | { | 37 | { |
38 | struct hexline *hx; | 38 | struct hexline *hx; |
39 | u8 reset; | 39 | u8 *buf; |
40 | int ret,pos=0; | 40 | int ret, pos = 0; |
41 | u16 cpu_cs_register = cypress[type].cpu_cs_register; | ||
41 | 42 | ||
42 | hx = kmalloc(sizeof(*hx), GFP_KERNEL); | 43 | buf = kmalloc(sizeof(*hx), GFP_KERNEL); |
43 | if (!hx) | 44 | if (!buf) |
44 | return -ENOMEM; | 45 | return -ENOMEM; |
46 | hx = (struct hexline *)buf; | ||
45 | 47 | ||
46 | /* stop the CPU */ | 48 | /* stop the CPU */ |
47 | reset = 1; | 49 | buf[0] = 1; |
48 | if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1) | 50 | if (usb_cypress_writemem(udev, cpu_cs_register, buf, 1) != 1) |
49 | err("could not stop the USB controller CPU."); | 51 | err("could not stop the USB controller CPU."); |
50 | 52 | ||
51 | while ((ret = dvb_usb_get_hexline(fw, hx, &pos)) > 0) { | 53 | while ((ret = dvb_usb_get_hexline(fw, hx, &pos)) > 0) { |
@@ -61,21 +63,21 @@ int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw | |||
61 | } | 63 | } |
62 | if (ret < 0) { | 64 | if (ret < 0) { |
63 | err("firmware download failed at %d with %d",pos,ret); | 65 | err("firmware download failed at %d with %d",pos,ret); |
64 | kfree(hx); | 66 | kfree(buf); |
65 | return ret; | 67 | return ret; |
66 | } | 68 | } |
67 | 69 | ||
68 | if (ret == 0) { | 70 | if (ret == 0) { |
69 | /* restart the CPU */ | 71 | /* restart the CPU */ |
70 | reset = 0; | 72 | buf[0] = 0; |
71 | if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) { | 73 | if (usb_cypress_writemem(udev, cpu_cs_register, buf, 1) != 1) { |
72 | err("could not restart the USB controller CPU."); | 74 | err("could not restart the USB controller CPU."); |
73 | ret = -EINVAL; | 75 | ret = -EINVAL; |
74 | } | 76 | } |
75 | } else | 77 | } else |
76 | ret = -EIO; | 78 | ret = -EIO; |
77 | 79 | ||
78 | kfree(hx); | 80 | kfree(buf); |
79 | 81 | ||
80 | return ret; | 82 | return ret; |
81 | } | 83 | } |