be2net: bug fix on returning an invalid nic descriptor
Subsystems (3)
PATCH 1/1 be2net: bug fix on returning an invalid nic descriptor
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.
--- drivers/net/ethernet/emulex/benet/be_cmds.c | 13 ++++--------- 1 files changed, 4 insertions(+), 9 deletions(-)
drivers/net/ethernet/emulex/benet/be_cmds.c +4 -9
@@ -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 */
Signature · 1 line
1.7.1
Quoted 13 lines
-----Original Message-----
From: Wei Yang [mailto:[email protected]]In function
be_get_nic_desc(), it will go through the descriptor array returned from f/w. By comparing thedesc_typefield, 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_countis less thanMAX_RESOURCE_DESC. In this case, even there is no nic descriptor, it will still return the lase descriptor since the i doesn't equal toMAX_RESOURCE_DESC.
Quoted 6 lines
This patch fix this issue by returning the descriptor when find it and return NULL for other cases.
Signed-off-by Wei Yang <[email protected]>Reviewed-by Gavin Shan <[email protected]>Reviewed-by Xiao Guangrong <[email protected]>
Thanks for the fix.
-Sathya
From: Wei Yang <[email protected]>
Date: Thu, 23 May 2013 09:58:22 +0800
Quoted 10 lines
In function
be_get_nic_desc(), it will go through the descriptor array returned from f/w. By comparing thedesc_typefield, 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_countis less thanMAX_RESOURCE_DESC. In this case, even there is no nic descriptor, it will still return the lase descriptor since the i doesn't equal toMAX_RESOURCE_DESC.
Quoted 6 lines
This patch fix this issue by returning the descriptor when find it and return NULL for other cases.
Signed-off-by Wei Yang <[email protected]>Reviewed-by Gavin Shan <[email protected]>Reviewed-by Xiao Guangrong <[email protected]>
Applied.
Quoted 13 lines · David Miller
From: Wei Yang <[email protected]>
Date: Thu, 23 May 2013 09:58:22 +0800Quoted 10 lines
In function
be_get_nic_desc(), it will go through the descriptor array returned from f/w. By comparing thedesc_typefield, 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_countis less thanMAX_RESOURCE_DESC. In this case, even there is no nic descriptor, it will still return the lase descriptor since the i doesn't equal toMAX_RESOURCE_DESC.
Quoted 8 lines
Quoted 6 lines
This patch fix this issue by returning the descriptor when find it and return NULL for other cases.
Signed-off-by Wei Yang <[email protected]>Reviewed-by Gavin Shan <[email protected]>Reviewed-by Xiao Guangrong <[email protected]>Applied.
Got it, Thanks~
Signature · 2 lines
Richard Yang Help you, Help me