OSDN Git Service

rsi: fix a double free bug in rsi_91x_deinit()
authorHui Peng <benquike@gmail.com>
Mon, 19 Aug 2019 22:02:29 +0000 (18:02 -0400)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 3 Sep 2019 13:54:48 +0000 (16:54 +0300)
commit8b51dc7291473093c821195c4b6af85fadedbc2f
tree0916f8bcb99e67232241dd779e793b8a8e340c58
parent13fa451568ab9e8b3074ef741477c7938c713c42
rsi: fix a double free bug in rsi_91x_deinit()

`dev` (struct rsi_91x_usbdev *) field of adapter
(struct rsi_91x_usbdev *) is allocated  and initialized in
`rsi_init_usb_interface`. If any error is detected in information
read from the device side,  `rsi_init_usb_interface` will be
freed. However, in the higher level error handling code in
`rsi_probe`, if error is detected, `rsi_91x_deinit` is called
again, in which `dev` will be freed again, resulting double free.

This patch fixes the double free by removing the free operation on
`dev` in `rsi_init_usb_interface`, because `rsi_91x_deinit` is also
used in `rsi_disconnect`, in that code path, the `dev` field is not
 (and thus needs to be) freed.

This bug was found in v4.19, but is also present in the latest version
of kernel. Fixes CVE-2019-15504.

Reported-by: Hui Peng <benquike@gmail.com>
Reported-by: Mathias Payer <mathias.payer@nebelwelt.net>
Signed-off-by: Hui Peng <benquike@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/rsi/rsi_91x_usb.c