Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1255535

Re: [PATCH 1/3] staging: wilc1000: Remove reference preceded by free

From Greg KH <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH 1/3] staging: wilc1000: Remove reference preceded by free
Date 2015-10-25 20:20 +0100
Message-ID <qnyZI-6T8-17@gated-at.bofh.it> (permalink)
References <qnfDH-5tK-5@gated-at.bofh.it> <qnfDH-5tK-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sun, Oct 25, 2015 at 04:01:23AM +0530, Punit Vara wrote:
> This patch is to the wilc_wfi_cfgoperations.c file that fixes up
> following error reported by coccicheck:
> 
> ERROR: reference preceded by free on line 1219
> 
> For (params->seq_len) <= 0 memory is already freed when
> (params->seq_len) >0 then memory was alloted. So there is no need to use
> kfree whenever params->seq_len <=0 remove it and place kfree inside
> (params->seq_len) >0 condition.
> 
> Signed-off-by: Punit Vara <punitvara@gmail.com>
> ---
>  drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> index bcbf1bd..9b3cf04 100644
> --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> @@ -1216,11 +1216,10 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
>  
>  				priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
>  
> -				kfree(priv->wilc_ptk[key_index]->seq);
> -
> -				if ((params->seq_len) > 0)
> +				if ((params->seq_len) > 0) {
> +					kfree(priv->wilc_ptk[key_index]->seq);
>  					priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
> -
> +				}

Are you sure about this?  It seems like you are changing the logic
here...

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/3] Staging: wilc1000: Remove coccicheck warnings and error Punit Vara <punitvara@gmail.com> - 2015-10-25 00:40 +0200
  [PATCH 3/3] Staging: wilc1000: Remove boolean comparision Punit Vara <punitvara@gmail.com> - 2015-10-25 00:40 +0200
  [PATCH 1/3] staging: wilc1000: Remove reference preceded by free Punit Vara <punitvara@gmail.com> - 2015-10-25 00:40 +0200
    Re: [PATCH 1/3] staging: wilc1000: Remove reference preceded by free Greg KH <gregkh@linuxfoundation.org> - 2015-10-25 20:20 +0100
      Re: [PATCH 1/3] staging: wilc1000: Remove reference preceded by free punit vara <punitvara@gmail.com> - 2015-10-25 20:40 +0100
        Re: [PATCH 1/3] staging: wilc1000: Remove reference preceded by free punit vara <punitvara@gmail.com> - 2015-10-25 21:00 +0100
          Re: [PATCH 1/3] staging: wilc1000: Remove reference preceded by free Greg KH <gregkh@linuxfoundation.org> - 2015-10-25 22:40 +0100
  [PATCH 2/3] Staging: wilc1000: Remove comparision of field address to NULL Punit Vara <punitvara@gmail.com> - 2015-10-25 00:40 +0200
    Re: [PATCH 2/3] Staging: wilc1000: Remove comparision of field  address to NULL Greg KH <gregkh@linuxfoundation.org> - 2015-10-25 20:20 +0100

csiph-web