From: Amitkumar Karwar <amitkarwar@gmail.com>
To: Kalle Valo <kvalo@codeaurora.org>
Cc: linux-wireless@vger.kernel.org,
Amitkumar Karwar <amit.karwar@redpinesignals.com>,
Prameela Rani Garnepudi <prameela.j04cs@gmail.com>
Subject: [PATCH 2/3] rsi: check length before USB read/write register
Date: Tue, 11 Jul 2017 19:57:52 +0530 [thread overview]
Message-ID: <1499783273-15428-2-git-send-email-amitkarwar@gmail.com> (raw)
In-Reply-To: <1499783273-15428-1-git-send-email-amitkarwar@gmail.com>
From: Amitkumar Karwar <amit.karwar@redpinesignals.com>
These checks are required. Otherwise we may end up getting
memory corruption if invalid length is passed.
Fixes: b97e9b94ad75c ("rsi: Add new host interface operations")
Signed-off-by: Amitkumar Karwar <amit.karwar@redpinesignals.com>
---
drivers/net/wireless/rsi/rsi_91x_usb.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c
index 99a520a..3d33ce9 100644
--- a/drivers/net/wireless/rsi/rsi_91x_usb.c
+++ b/drivers/net/wireless/rsi/rsi_91x_usb.c
@@ -166,6 +166,9 @@ static int rsi_usb_reg_read(struct usb_device *usbdev,
if (!buf)
return status;
+ if (len > RSI_USB_CTRL_BUF_SIZE)
+ return -EINVAL;
+
status = usb_control_msg(usbdev,
usb_rcvctrlpipe(usbdev, 0),
USB_VENDOR_REGISTER_READ,
@@ -208,6 +211,9 @@ static int rsi_usb_reg_write(struct usb_device *usbdev,
if (!usb_reg_buf)
return status;
+ if (len > RSI_USB_CTRL_BUF_SIZE)
+ return -EINVAL;
+
usb_reg_buf[0] = (value & 0x00ff);
usb_reg_buf[1] = (value & 0xff00) >> 8;
usb_reg_buf[2] = 0x0;
--
2.7.4
next prev parent reply other threads:[~2017-07-11 14:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-11 14:27 [PATCH 1/3] rsi: use macro for allocating USB buffer Amitkumar Karwar
2017-07-11 14:27 ` Amitkumar Karwar [this message]
2017-07-11 14:27 ` [PATCH 3/3] rsi: fix static checker warning Amitkumar Karwar
2017-07-28 14:28 ` [1/3] rsi: use macro for allocating USB buffer Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1499783273-15428-2-git-send-email-amitkarwar@gmail.com \
--to=amitkarwar@gmail.com \
--cc=amit.karwar@redpinesignals.com \
--cc=kvalo@codeaurora.org \
--cc=linux-wireless@vger.kernel.org \
--cc=prameela.j04cs@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).