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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 Dec 2017 08:53:07 +0000 (09:53 +0100)
commitf52688ce0d7bb5bd6932be99faec931be59d9c63
tree3c5b409cceaeacdeabc9221f8e3cb6d02bf2d0d6
parentad199b18a9c00729bd000cf3565f6a45ebd4e177
rsi: fix memory leak on buf and usb_reg_buf

[ Upstream commit d35ef8f846c72d84bfccf239c248c84f79c3a7e8 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/rsi/rsi_91x_usb.c