wl12xx: Validate FEM index from ini file and FW
authorPontus Fuchs <pontus.fuchs@gmail.com>
Tue, 18 Oct 2011 07:23:41 +0000 (09:23 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 12 Jan 2012 19:29:21 +0000 (11:29 -0800)
commit 2131d3c2f99b081806fdae7662c92fe6acda52af upstream.

Check for out of bound FEM index to prevent reading beyond ini
memory end.

Signed-off-by: Pontus Fuchs <pontus.fuchs@gmail.com>
Reviewed-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/net/wireless/wl12xx/cmd.c

index a52299e..54a0d66 100644 (file)
@@ -120,6 +120,11 @@ int wl1271_cmd_general_parms(struct wl1271 *wl)
        if (!wl->nvs)
                return -ENODEV;
 
+       if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) {
+               wl1271_warning("FEM index from INI out of bounds");
+               return -EINVAL;
+       }
+
        gen_parms = kzalloc(sizeof(*gen_parms), GFP_KERNEL);
        if (!gen_parms)
                return -ENOMEM;
@@ -143,6 +148,12 @@ int wl1271_cmd_general_parms(struct wl1271 *wl)
        gp->tx_bip_fem_manufacturer =
                gen_parms->general_params.tx_bip_fem_manufacturer;
 
+       if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) {
+               wl1271_warning("FEM index from FW out of bounds");
+               ret = -EINVAL;
+               goto out;
+       }
+
        wl1271_debug(DEBUG_CMD, "FEM autodetect: %s, manufacturer: %d\n",
                     answer ? "auto" : "manual", gp->tx_bip_fem_manufacturer);
 
@@ -162,6 +173,11 @@ int wl128x_cmd_general_parms(struct wl1271 *wl)
        if (!wl->nvs)
                return -ENODEV;
 
+       if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) {
+               wl1271_warning("FEM index from ini out of bounds");
+               return -EINVAL;
+       }
+
        gen_parms = kzalloc(sizeof(*gen_parms), GFP_KERNEL);
        if (!gen_parms)
                return -ENOMEM;
@@ -186,6 +202,12 @@ int wl128x_cmd_general_parms(struct wl1271 *wl)
        gp->tx_bip_fem_manufacturer =
                gen_parms->general_params.tx_bip_fem_manufacturer;
 
+       if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) {
+               wl1271_warning("FEM index from FW out of bounds");
+               ret = -EINVAL;
+               goto out;
+       }
+
        wl1271_debug(DEBUG_CMD, "FEM autodetect: %s, manufacturer: %d\n",
                     answer ? "auto" : "manual", gp->tx_bip_fem_manufacturer);