All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roel Kluin <roel.kluin@gmail.com>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com>,
	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: Sun, 22 Nov 2009 15:31:34 +0100	[thread overview]
Message-ID: <4B094B46.8070901@gmail.com> (raw)
In-Reply-To: <4B083EE2.9040301@gmail.com>

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++)

  reply	other threads:[~2009-11-22 14:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-21 19:26 [PATCH] e1000e: Use sizeof struct rather than pointer in e1000_get_eeprom() Roel Kluin
2009-11-22 14:31 ` Roel Kluin [this message]
2009-11-23 19:39   ` Jeff Kirsher

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=4B094B46.8070901@gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bruce.w.allan@intel.com \
    --cc=e1000-devel@lists.sourceforge.net \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=john.ronciak@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.p.waskiewicz.jr@intel.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 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.