Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jesse Brandeburg <jesse.brandeburg@intel.com>
To: Petr Oros <poros@redhat.com>, <netdev@vger.kernel.org>
Cc: intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org,
	edumazet@google.com, anthony.l.nguyen@intel.com, kuba@kernel.org,
	pabeni@redhat.com, davem@davemloft.net
Subject: Re: [Intel-wired-lan] [PATCH net v2] ice: copy last block omitted in ice_get_module_eeprom()
Date: Wed, 1 Mar 2023 11:26:55 -0800	[thread overview]
Message-ID: <d062a735-ed89-d437-16cc-ca7456c7de08@intel.com> (raw)
In-Reply-To: <20230301171452.2514734-1-poros@redhat.com>

On 3/1/2023 9:14 AM, Petr Oros wrote:

>  drivers/net/ethernet/intel/ice/ice_ethtool.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> index b360bd8f15998b..1dc3f9fc74bdfb 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> @@ -4293,6 +4293,7 @@ ice_get_module_eeprom(struct net_device *netdev,
>  	bool is_sfp = false;
>  	unsigned int i, j;
>  	u16 offset = 0;
> +	u32 copy_len;

copy_len should only be declared in the "if" below so that it's only
declared in the context it is used.

>  	u8 page = 0;
>  	int status;
>  
> @@ -4354,8 +4355,9 @@ ice_get_module_eeprom(struct net_device *netdev,
>  			}
>  
>  			/* Make sure we have enough room for the new block */
> -			if ((i + SFF_READ_BLOCK_SIZE) < ee->len)
> -				memcpy(data + i, value, SFF_READ_BLOCK_SIZE);
> +			copy_len = min_t(u32, SFF_READ_BLOCK_SIZE,
> +					 ee->len - i);

also this line can be unwrapped now.

> +			memcpy(data + i, value, copy_len);
>  		}
>  	}
>  	return 0;

I've tested this and it fixes the problem. Interestingly, the ethtool
application when compiled without netlink support parsed the output
correctly so caused a bit of confusion around this issue.

Thank you Petr!

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

      reply	other threads:[~2023-03-01 19:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-28 20:41 [Intel-wired-lan] [PATCH net] ice: copy last block omitted in ice_get_module_eeprom() Petr Oros
2023-03-01 17:14 ` [Intel-wired-lan] [PATCH net v2] " Petr Oros
2023-03-01 19:26   ` Jesse Brandeburg [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=d062a735-ed89-d437-16cc-ca7456c7de08@intel.com \
    --to=jesse.brandeburg@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=poros@redhat.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