wl1251: Update wl->nvs_len after wl->nvs is valid
authorPali Rohár <pali.rohar@gmail.com>
Thu, 9 Nov 2017 23:38:23 +0000 (00:38 +0100)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 27 Feb 2018 13:50:42 +0000 (15:50 +0200)
If kmemdup fails, then wl->nvs_len will contain invalid non-zero size.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ti/wl1251/main.c

index 037defd..412fbd4 100644 (file)
@@ -122,8 +122,7 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
                goto out;
        }
 
-       wl->nvs_len = fw->size;
-       wl->nvs = kmemdup(fw->data, wl->nvs_len, GFP_KERNEL);
+       wl->nvs = kmemdup(fw->data, fw->size, GFP_KERNEL);
 
        if (!wl->nvs) {
                wl1251_error("could not allocate memory for the nvs file");
@@ -131,6 +130,8 @@ static int wl1251_fetch_nvs(struct wl1251 *wl)
                goto out;
        }
 
+       wl->nvs_len = fw->size;
+
        ret = 0;
 
 out: