All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] be2net: bug fix on returning an invalid nic descriptor
@ 2013-05-23  1:58 Wei Yang
  2013-05-23  4:32 ` Perla, Sathya
  2013-05-24  1:57 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Wei Yang @ 2013-05-23  1:58 UTC (permalink / raw)
  To: sathya.perla, netdev; +Cc: Wei Yang

In function be_get_nic_desc(), it will go through the descriptor array
returned from f/w. By comparing the desc_type field, it determines whether
there is a nic descriptor in the array or not. In the case of no nic
descriptor, this function should return NULL.

The code may return an invalide descriptor, when there is no nic descriptor
in the array and the desc_count is less than MAX_RESOURCE_DESC. In this case,
even there is no nic descriptor, it will still return the lase descriptor
since the i doesn't equal to MAX_RESOURCE_DESC.

This patch fix this issue by returning the descriptor when find it and return
NULL for other cases.

Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
Reviewed-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Reviewed-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
 drivers/net/ethernet/emulex/benet/be_cmds.c |   13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index fd7b547..a236ecd 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -2976,22 +2976,17 @@ static struct be_nic_resource_desc *be_get_nic_desc(u8 *buf, u32 desc_count,
 	for (i = 0; i < desc_count; i++) {
 		desc->desc_len = desc->desc_len ? : RESOURCE_DESC_SIZE;
 		if (((void *)desc + desc->desc_len) >
-		    (void *)(buf + max_buf_size)) {
-			desc = NULL;
-			break;
-		}
+		    (void *)(buf + max_buf_size))
+			return NULL;
 
 		if (desc->desc_type == NIC_RESOURCE_DESC_TYPE_V0 ||
 		    desc->desc_type == NIC_RESOURCE_DESC_TYPE_V1)
-			break;
+			return desc;
 
 		desc = (void *)desc + desc->desc_len;
 	}
 
-	if (!desc || i == MAX_RESOURCE_DESC)
-		return NULL;
-
-	return desc;
+	return NULL;
 }
 
 /* Uses Mbox */
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH] be2net: bug fix on returning an invalid nic descriptor
  2013-05-23  1:58 [PATCH] be2net: bug fix on returning an invalid nic descriptor Wei Yang
@ 2013-05-23  4:32 ` Perla, Sathya
  2013-05-24  1:57 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: Perla, Sathya @ 2013-05-23  4:32 UTC (permalink / raw)
  To: Wei Yang, netdev

> -----Original Message-----
> From: Wei Yang [mailto:weiyang@linux.vnet.ibm.com]
> 
> In function be_get_nic_desc(), it will go through the descriptor array
> returned from f/w. By comparing the desc_type field, it determines whether
> there is a nic descriptor in the array or not. In the case of no nic descriptor,
> this function should return NULL.
> 
> The code may return an invalide descriptor, when there is no nic descriptor in
> the array and the desc_count is less than MAX_RESOURCE_DESC. In this
> case, even there is no nic descriptor, it will still return the lase descriptor
> since the i doesn't equal to MAX_RESOURCE_DESC.
> 
> This patch fix this issue by returning the descriptor when find it and return
> NULL for other cases.
> 
> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
> Reviewed-by: Gavin Shan <shangw@linux.vnet.ibm.com>
> Reviewed-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>

Acked-by: Sathya Perla <sathya.perla@emulex.com>

Thanks for the fix.
-Sathya

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] be2net: bug fix on returning an invalid nic descriptor
  2013-05-23  1:58 [PATCH] be2net: bug fix on returning an invalid nic descriptor Wei Yang
  2013-05-23  4:32 ` Perla, Sathya
@ 2013-05-24  1:57 ` David Miller
  2013-05-24  2:12   ` Wei Yang
  1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2013-05-24  1:57 UTC (permalink / raw)
  To: weiyang; +Cc: sathya.perla, netdev

From: Wei Yang <weiyang@linux.vnet.ibm.com>
Date: Thu, 23 May 2013 09:58:22 +0800

> In function be_get_nic_desc(), it will go through the descriptor array
> returned from f/w. By comparing the desc_type field, it determines whether
> there is a nic descriptor in the array or not. In the case of no nic
> descriptor, this function should return NULL.
> 
> The code may return an invalide descriptor, when there is no nic descriptor
> in the array and the desc_count is less than MAX_RESOURCE_DESC. In this case,
> even there is no nic descriptor, it will still return the lase descriptor
> since the i doesn't equal to MAX_RESOURCE_DESC.
> 
> This patch fix this issue by returning the descriptor when find it and return
> NULL for other cases.
> 
> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
> Reviewed-by: Gavin Shan <shangw@linux.vnet.ibm.com>
> Reviewed-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] be2net: bug fix on returning an invalid nic descriptor
  2013-05-24  1:57 ` David Miller
@ 2013-05-24  2:12   ` Wei Yang
  0 siblings, 0 replies; 4+ messages in thread
From: Wei Yang @ 2013-05-24  2:12 UTC (permalink / raw)
  To: David Miller; +Cc: weiyang, sathya.perla, netdev

On Thu, May 23, 2013 at 06:57:04PM -0700, David Miller wrote:
>From: Wei Yang <weiyang@linux.vnet.ibm.com>
>Date: Thu, 23 May 2013 09:58:22 +0800
>
>> In function be_get_nic_desc(), it will go through the descriptor array
>> returned from f/w. By comparing the desc_type field, it determines whether
>> there is a nic descriptor in the array or not. In the case of no nic
>> descriptor, this function should return NULL.
>> 
>> The code may return an invalide descriptor, when there is no nic descriptor
>> in the array and the desc_count is less than MAX_RESOURCE_DESC. In this case,
>> even there is no nic descriptor, it will still return the lase descriptor
>> since the i doesn't equal to MAX_RESOURCE_DESC.
>> 
>> This patch fix this issue by returning the descriptor when find it and return
>> NULL for other cases.
>> 
>> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
>> Reviewed-by: Gavin Shan <shangw@linux.vnet.ibm.com>
>> Reviewed-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
>
>Applied.

Got it, Thanks~

-- 
Richard Yang
Help you, Help me

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-05-24  2:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-23  1:58 [PATCH] be2net: bug fix on returning an invalid nic descriptor Wei Yang
2013-05-23  4:32 ` Perla, Sathya
2013-05-24  1:57 ` David Miller
2013-05-24  2:12   ` Wei Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.