From: Luciano Coelho <[email protected]>

Check for the minimum required buffer length in wlcore_cmd_send() and
wlcore_cmd_configure_failsafe.  This ensures that we will never try to
use a buffer that is smaller than the required header.

Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Luciano Coelho <[email protected]>
---

NOTE: this is only compile-tested.

drivers/net/wireless/ti/wlcore/cmd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/ti/wlcore/cmd.c 
b/drivers/net/wireless/ti/wlcore/cmd.c
index 05604ee..5c6f3c8 100644
--- a/drivers/net/wireless/ti/wlcore/cmd.c
+++ b/drivers/net/wireless/ti/wlcore/cmd.c
@@ -64,6 +64,9 @@ static int __wlcore_cmd_send(struct wl1271 *wl, u16 id, void 
*buf,
                     id != CMD_STOP_FWLOGGER))
                return -EIO;
 
+       if (WARN_ON_ONCE(len < sizeof(*cmd)))
+               return -EIO;
+
        cmd = buf;
        cmd->id = cpu_to_le16(id);
        cmd->status = 0;
@@ -891,6 +894,9 @@ int wlcore_cmd_configure_failsafe(struct wl1271 *wl, u16 
id, void *buf,
 
        wl1271_debug(DEBUG_CMD, "cmd configure (%d)", id);
 
+       if (WARN_ON_ONCE(len < sizeof(*acx)))
+               return -EIO;
+
        acx->id = cpu_to_le16(id);
 
        /* payload length, does not include any headers */
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to