Warninig is printed if precision is lost - it can't happen at moment as
all get_key implementations return either -1 or small buffers.

Signed-off-by: Mateusz Kulikowski <mateusz.kulikow...@gmail.com>
---
 drivers/staging/rtl8192e/rtllib_wx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib_wx.c 
b/drivers/staging/rtl8192e/rtllib_wx.c
index 2ac1617..22bea5a 100644
--- a/drivers/staging/rtl8192e/rtllib_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_wx.c
@@ -510,7 +510,10 @@ int rtllib_wx_get_encode(struct rtllib_device *ieee,
                return 0;
        }
        len = crypt->ops->get_key(keybuf, SCM_KEY_LEN, NULL, crypt->priv);
-       erq->length = (len >= 0 ? len : 0);
+       if (len > U16_MAX)
+               netdev_err(ieee->dev, "Too long key returned.\n");
+
+       erq->length = max(len, 0);
 
        erq->flags |= IW_ENCODE_ENABLED;
 
-- 
1.8.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to