[prev in list] [next in list] [prev in thread] [next in thread]
List: e1000-devel
Subject: Re: [E1000-devel] [PATCH] e1000e: Use sizeof struct rather than
From: Jeff Kirsher <jeffrey.t.kirsher () intel ! com>
Date: 2009-11-23 19:39:30
Message-ID: 9929d2390911231139i4f5d5b74i92f8562d01c4159a () mail ! gmail ! com
[Download RAW message or body]
On Sun, Nov 22, 2009 at 06:31, Roel Kluin <roel.kluin@gmail.com> wrote:
> Don't use the sizeof the pointer to clear the result
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> drivers/net/e1000e/ethtool.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
>> - memset(eeprom_buff, 0xff, sizeof(eeprom_buff));
>> + memset(eeprom_buff, 0xff, sizeof(*eeprom_buff));
>
> No it's probably still not correct, eeprom_buff was kmalloc'd with:
>
> eeprom_buff = kmalloc(sizeof(u16) *
> (last_word - first_word + 1), GFP_KERNEL);
>
> How about:
>
> diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
> index 1bf4d2a..5b276c0 100644
> --- a/drivers/net/e1000e/ethtool.c
> +++ b/drivers/net/e1000e/ethtool.c
> @@ -508,7 +508,8 @@ static int e1000_get_eeprom(struct net_device *netdev,
>
> if (ret_val) {
> /* a read error occurred, throw away the result */
> - memset(eeprom_buff, 0xff, sizeof(eeprom_buff));
> + memset(eeprom_buff, 0xff, sizeof(u16) *
> + (last_word - first_word + 1));
> } else {
> /* Device's eeprom is always little-endian, word addressable */
> for (i = 0; i < last_word - first_word + 1; i++)
> --
Thanks Roel. I will add this to my tree for testing and review.
--
Cheers,
Jeff
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic