From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>,
Bruce Allan <bruce.w.allan@intel.com>,
PJ Waskiewicz <peter.p.waskiewicz.jr@intel.com>,
John Ronciak <john.ronciak@intel.com>,
e1000-devel@lists.sourceforge.net,
Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] e1000e: Use sizeof struct rather than pointer in e1000_get_eeprom()
Date: Mon, 23 Nov 2009 11:39:30 -0800 [thread overview]
Message-ID: <9929d2390911231139i4f5d5b74i92f8562d01c4159a@mail.gmail.com> (raw)
In-Reply-To: <4B094B46.8070901@gmail.com>
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
prev parent reply other threads:[~2009-11-23 19:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-21 19:26 Roel Kluin
2009-11-22 14:31 ` Roel Kluin
2009-11-23 19:39 ` Jeff Kirsher [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9929d2390911231139i4f5d5b74i92f8562d01c4159a@mail.gmail.com \
--to=jeffrey.t.kirsher@intel.com \
--cc=akpm@linux-foundation.org \
--cc=bruce.w.allan@intel.com \
--cc=e1000-devel@lists.sourceforge.net \
--cc=jesse.brandeburg@intel.com \
--cc=john.ronciak@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.p.waskiewicz.jr@intel.com \
--cc=roel.kluin@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®