public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] netxen: memory corruption by netxen_p3_get_mac_addr.
@ 2012-03-03 17:01 santosh nayak
  2012-03-03 18:35 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: santosh nayak @ 2012-03-03 17:01 UTC (permalink / raw)
  To: sony.chacko
  Cc: rajesh.borundia, netdev, linux-kernel, kernel-janitors,
	Santosh Nayak

From: Santosh Nayak <santoshprasadnayak@gmail.com>

'mac_hi' and 'mac_lo' are 32 bit unsinged int but we are modifing
64 bit of memory during mac calculation. To fix this issue define
a local variable of 64 bit and do mac calculation.

Remove 'le64_to_cpu' to fix endian issue.

Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>
---
 drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
index 0f81287..7ea930b 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
@@ -1069,7 +1069,8 @@ int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 *mac)
 
 int netxen_p3_get_mac_addr(struct netxen_adapter *adapter, u64 *mac)
 {
-	uint32_t crbaddr, mac_hi, mac_lo;
+	uint32_t crbaddr;
+	u64 mac_hi, mac_lo;
 	int pci_func = adapter->ahw.pci_func;
 
 	crbaddr = CRB_MAC_BLOCK_START +
@@ -1079,9 +1080,9 @@ int netxen_p3_get_mac_addr(struct netxen_adapter *adapter, u64 *mac)
 	mac_hi = NXRD32(adapter, crbaddr+4);
 
 	if (pci_func & 1)
-		*mac = le64_to_cpu((mac_lo >> 16) | ((u64)mac_hi << 16));
+		*mac = (mac_lo >> 16) | (mac_hi << 16);
 	else
-		*mac = le64_to_cpu((u64)mac_lo | ((u64)mac_hi << 32));
+		*mac = mac_lo | (mac_hi << 32);
 
 	return 0;
 }
-- 
1.7.4.4


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

* Re: [PATCH] netxen: memory corruption by netxen_p3_get_mac_addr.
  2012-03-03 17:01 [PATCH] netxen: memory corruption by netxen_p3_get_mac_addr santosh nayak
@ 2012-03-03 18:35 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2012-03-03 18:35 UTC (permalink / raw)
  To: santosh nayak
  Cc: sony.chacko, rajesh.borundia, netdev, linux-kernel,
	Dhananjay Phadke, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1994 bytes --]

On Sat, Mar 03, 2012 at 10:31:27PM +0530, santosh nayak wrote:
> From: Santosh Nayak <santoshprasadnayak@gmail.com>
> 
> 'mac_hi' and 'mac_lo' are 32 bit unsinged int but we are modifing
> 64 bit of memory during mac calculation. To fix this issue define
> a local variable of 64 bit and do mac calculation.
> 

I'm not seeing any memory corruption.  How do you figure?

> Remove 'le64_to_cpu' to fix endian issue.

I've add Dhananjay to the CC list to comment on the endian change.

regards,
dan carpenter

> 
> Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>
> ---
>  drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
> index 0f81287..7ea930b 100644
> --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
> +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
> @@ -1069,7 +1069,8 @@ int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 *mac)
>  
>  int netxen_p3_get_mac_addr(struct netxen_adapter *adapter, u64 *mac)
>  {
> -	uint32_t crbaddr, mac_hi, mac_lo;
> +	uint32_t crbaddr;
> +	u64 mac_hi, mac_lo;
>  	int pci_func = adapter->ahw.pci_func;
>  
>  	crbaddr = CRB_MAC_BLOCK_START +
> @@ -1079,9 +1080,9 @@ int netxen_p3_get_mac_addr(struct netxen_adapter *adapter, u64 *mac)
>  	mac_hi = NXRD32(adapter, crbaddr+4);
>  
>  	if (pci_func & 1)
> -		*mac = le64_to_cpu((mac_lo >> 16) | ((u64)mac_hi << 16));
> +		*mac = (mac_lo >> 16) | (mac_hi << 16);
>  	else
> -		*mac = le64_to_cpu((u64)mac_lo | ((u64)mac_hi << 32));
> +		*mac = mac_lo | (mac_hi << 32);
>  
>  	return 0;
>  }
> -- 
> 1.7.4.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2012-03-03 18:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-03 17:01 [PATCH] netxen: memory corruption by netxen_p3_get_mac_addr santosh nayak
2012-03-03 18:35 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox