Browse Source

staging: wilc1000: free allocated memory in edit and add station functions

Added fix to free the allocated memory in case of failure to enqueue
the command.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ajay Singh 7 years ago
parent
commit
7ab3e668aa
1 changed files with 6 additions and 2 deletions
  1. 6 2
      drivers/staging/wilc1000/host_interface.c

+ 6 - 2
drivers/staging/wilc1000/host_interface.c

@@ -3721,8 +3721,10 @@ int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param)
 	}
 
 	result = wilc_enqueue_cmd(&msg);
-	if (result)
+	if (result) {
 		netdev_err(vif->ndev, "wilc_mq_send fail\n");
+		kfree(add_sta_info->rates);
+	}
 	return result;
 }
 
@@ -3805,8 +3807,10 @@ int wilc_edit_station(struct wilc_vif *vif,
 	}
 
 	result = wilc_enqueue_cmd(&msg);
-	if (result)
+	if (result) {
 		netdev_err(vif->ndev, "wilc_mq_send fail\n");
+		kfree(add_sta_info->rates);
+	}
 
 	return result;
 }