rsi: fix memory leak on buf and usb_reg_buf
authorColin Ian King <colin.king@canonical.com>
Thu, 16 Nov 2017 17:39:18 +0000 (17:39 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 18 Nov 2017 01:32:41 +0000 (10:32 +0900)
commitd35ef8f846c72d84bfccf239c248c84f79c3a7e8
treedd3b11543c59e224056177959bc16fe9120f31d9
parent17e48577752a61197a7e5f4922db45b3a5af5068
rsi: fix memory leak on buf and usb_reg_buf

In the cases where len is too long, the error return path fails to
kfree allocated buffers buf and usb_reg_buf.  The simplest fix is to
perform the sanity check on len before the allocations to avoid having
to do the kfree'ing in the first place.

Detected by CoverityScan, CID#1452258,1452259 ("Resource Leak")

Fixes: 59f73e2ae185 ("rsi: check length before USB read/write register")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/wireless/rsi/rsi_91x_usb.c