diff options
author | Stefan Brüns <stefan.bruens@rwth-aachen.de> | 2017-02-05 09:57:59 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-04-21 03:31:24 -0400 |
commit | fb00319317c152bf3528df13a54c28bf8c5daa55 (patch) | |
tree | 3678005dc4b516587be3b7a5ad576667d4153fe8 | |
parent | 28d1e8b7ef81d254583f68627095f8a85e39597d (diff) |
cxusb: Use a dma capable buffer also for reading
commit 3f190e3aec212fc8c61e202c51400afa7384d4bc upstream.
Commit 17ce039b4e54 ("[media] cxusb: don't do DMA on stack")
added a kmalloc'ed bounce buffer for writes, but missed to do the same
for reads. As the read only happens after the write is finished, we can
reuse the same buffer.
As dvb_usb_generic_rw handles a read length of 0 by itself, avoid calling
it using the dvb_usb_generic_read wrapper function.
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Brad Spengler <spender@grsecurity.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/media/usb/dvb-usb/cxusb.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c index 243403081fa5..9fd43a37154c 100644 --- a/drivers/media/usb/dvb-usb/cxusb.c +++ b/drivers/media/usb/dvb-usb/cxusb.c | |||
@@ -59,23 +59,24 @@ static int cxusb_ctrl_msg(struct dvb_usb_device *d, | |||
59 | u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen) | 59 | u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen) |
60 | { | 60 | { |
61 | struct cxusb_state *st = d->priv; | 61 | struct cxusb_state *st = d->priv; |
62 | int ret, wo; | 62 | int ret; |
63 | 63 | ||
64 | if (1 + wlen > MAX_XFER_SIZE) { | 64 | if (1 + wlen > MAX_XFER_SIZE) { |
65 | warn("i2c wr: len=%d is too big!\n", wlen); | 65 | warn("i2c wr: len=%d is too big!\n", wlen); |
66 | return -EOPNOTSUPP; | 66 | return -EOPNOTSUPP; |
67 | } | 67 | } |
68 | 68 | ||
69 | wo = (rbuf == NULL || rlen == 0); /* write-only */ | 69 | if (rlen > MAX_XFER_SIZE) { |
70 | warn("i2c rd: len=%d is too big!\n", rlen); | ||
71 | return -EOPNOTSUPP; | ||
72 | } | ||
70 | 73 | ||
71 | mutex_lock(&d->data_mutex); | 74 | mutex_lock(&d->data_mutex); |
72 | st->data[0] = cmd; | 75 | st->data[0] = cmd; |
73 | memcpy(&st->data[1], wbuf, wlen); | 76 | memcpy(&st->data[1], wbuf, wlen); |
74 | if (wo) | 77 | ret = dvb_usb_generic_rw(d, st->data, 1 + wlen, st->data, rlen, 0); |
75 | ret = dvb_usb_generic_write(d, st->data, 1 + wlen); | 78 | if (!ret && rbuf && rlen) |
76 | else | 79 | memcpy(rbuf, st->data, rlen); |
77 | ret = dvb_usb_generic_rw(d, st->data, 1 + wlen, | ||
78 | rbuf, rlen, 0); | ||
79 | 80 | ||
80 | mutex_unlock(&d->data_mutex); | 81 | mutex_unlock(&d->data_mutex); |
81 | return ret; | 82 | return ret; |