cw1200: Don't leak memory if krealloc failes
authorJohannes Thumshirn <jthumshirn@suse.de>
Fri, 30 Sep 2016 12:39:17 +0000 (14:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Dec 2018 08:48:04 +0000 (09:48 +0100)
commitaba29c20de48fae8ab8cf13d6a31c9a8bd5e16eb
treee2f546c9aebe3f9aa48224c95b2d294c619eadac
parent41d1c56f2de86540f2933bf18e85297994c238e0
cw1200: Don't leak memory if krealloc failes

commit 9afdd6128c39f42398041bb2e017d8df0dcebcd1 upstream.

The call to krealloc() in wsm_buf_reserve() directly assigns the newly
returned memory to buf->begin. This is all fine except when krealloc()
failes we loose the ability to free the old memory pointed to by
buf->begin. If we just create a temporary variable to assign memory to
and assign the memory to it we can mitigate the memory leak.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/cw1200/wsm.c