staging: wilc1000: use sizeof(variable) for memory allocated to store key info
authorAjay Singh <ajay.kathat@microchip.com>
Mon, 23 Apr 2018 16:33:20 +0000 (22:03 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Apr 2018 13:54:15 +0000 (15:54 +0200)
Changes to fix below checkpatch reported issues.

CHECK: Prefer kmalloc(sizeof(*priv->wilc_gtk[idx])...) over
kmalloc(sizeof(struct wilc_wfi_key)...)

CHECK: Prefer kmalloc(sizeof(*priv->wilc_ptk[idx])...) over
kmalloc(sizeof(struct wilc_wfi_key)...)

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>
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c

index 1c9864bb88dd0a91689ec0acb99acb839a7c63fb..5bd294dd21abd7cd50bf5fa0392d78473e78dc23 100644 (file)
@@ -870,15 +870,15 @@ static inline void wilc_wfi_cfg_copy_wep_info(struct wilc_priv *priv,
 static int wilc_wfi_cfg_allocate_wpa_entry(struct wilc_priv *priv, u8 idx)
 {
        if (!priv->wilc_gtk[idx]) {
-               priv->wilc_gtk[idx] = kzalloc(sizeof(struct wilc_wfi_key),
-                                              GFP_KERNEL);
+               priv->wilc_gtk[idx] = kzalloc(sizeof(*priv->wilc_gtk[idx]),
+                                             GFP_KERNEL);
                if (!priv->wilc_gtk[idx])
                        return -ENOMEM;
        }
 
        if (!priv->wilc_ptk[idx]) {
-               priv->wilc_ptk[idx] = kzalloc(sizeof(struct wilc_wfi_key),
-                                              GFP_KERNEL);
+               priv->wilc_ptk[idx] = kzalloc(sizeof(*priv->wilc_ptk[idx]),
+                                             GFP_KERNEL);
                if (!priv->wilc_ptk[idx])
                        return -ENOMEM;
        }