linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bnxt_en: Fix an error handling path in 'bnxt_get_module_eeprom()'
@ 2017-11-21 19:46 Christophe JAILLET
  2017-11-23 17:31 ` David Miller
  2017-11-28 15:56 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2017-11-21 19:46 UTC (permalink / raw)
  To: michael.chan; +Cc: netdev, linux-kernel, kernel-janitors, Christophe JAILLET

Error code returned by 'bnxt_read_sfp_module_eeprom_info()' is handled a
few lines above when reading the A0 portion of the EEPROM.
The same should be done when reading the A2 portion of the EEPROM.

In order to correctly propagate an error, update 'rc' in this 2nd call as
well, otherwise 0 (success) is returned.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Un-tested.

If not testing the result of the 2nd call was done on purpose, it should be
documented.
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index 7ce1d4b7e67d..b13ce5ebde8d 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -2136,8 +2136,8 @@ static int bnxt_get_module_eeprom(struct net_device *dev,
 	/* Read A2 portion of the EEPROM */
 	if (length) {
 		start -= ETH_MODULE_SFF_8436_LEN;
-		bnxt_read_sfp_module_eeprom_info(bp, I2C_DEV_ADDR_A2, 1, start,
-						 length, data);
+		rc = bnxt_read_sfp_module_eeprom_info(bp, I2C_DEV_ADDR_A2, 1,
+						      start, length, data);
 	}
 	return rc;
 }
-- 
2.14.1

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

* Re: [PATCH] bnxt_en: Fix an error handling path in 'bnxt_get_module_eeprom()'
  2017-11-21 19:46 [PATCH] bnxt_en: Fix an error handling path in 'bnxt_get_module_eeprom()' Christophe JAILLET
@ 2017-11-23 17:31 ` David Miller
  2017-11-28 15:56 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2017-11-23 17:31 UTC (permalink / raw)
  To: christophe.jaillet; +Cc: michael.chan, netdev, linux-kernel, kernel-janitors

From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date: Tue, 21 Nov 2017 20:46:49 +0100

> Error code returned by 'bnxt_read_sfp_module_eeprom_info()' is handled a
> few lines above when reading the A0 portion of the EEPROM.
> The same should be done when reading the A2 portion of the EEPROM.
> 
> In order to correctly propagate an error, update 'rc' in this 2nd call as
> well, otherwise 0 (success) is returned.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Michael, please take a look at this.

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

* Re: [PATCH] bnxt_en: Fix an error handling path in 'bnxt_get_module_eeprom()'
  2017-11-21 19:46 [PATCH] bnxt_en: Fix an error handling path in 'bnxt_get_module_eeprom()' Christophe JAILLET
  2017-11-23 17:31 ` David Miller
@ 2017-11-28 15:56 ` David Miller
  2017-11-28 17:11   ` Michael Chan
  1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2017-11-28 15:56 UTC (permalink / raw)
  To: christophe.jaillet; +Cc: michael.chan, netdev, linux-kernel, kernel-janitors

From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date: Tue, 21 Nov 2017 20:46:49 +0100

> Error code returned by 'bnxt_read_sfp_module_eeprom_info()' is handled a
> few lines above when reading the A0 portion of the EEPROM.
> The same should be done when reading the A2 portion of the EEPROM.
> 
> In order to correctly propagate an error, update 'rc' in this 2nd call as
> well, otherwise 0 (success) is returned.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Patch applied, thanks Chrisophe.

I cannot see any legitimate reason to ignore errors returned here, as
an error would mean a partial read back of the data to the caller.

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

* Re: [PATCH] bnxt_en: Fix an error handling path in 'bnxt_get_module_eeprom()'
  2017-11-28 15:56 ` David Miller
@ 2017-11-28 17:11   ` Michael Chan
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Chan @ 2017-11-28 17:11 UTC (permalink / raw)
  To: David Miller; +Cc: Christophe JAILLET, Netdev, open list, kernel-janitors

On Tue, Nov 28, 2017 at 7:56 AM, David Miller <davem@davemloft.net> wrote:
> From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Date: Tue, 21 Nov 2017 20:46:49 +0100
>
>> Error code returned by 'bnxt_read_sfp_module_eeprom_info()' is handled a
>> few lines above when reading the A0 portion of the EEPROM.
>> The same should be done when reading the A2 portion of the EEPROM.
>>
>> In order to correctly propagate an error, update 'rc' in this 2nd call as
>> well, otherwise 0 (success) is returned.
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>
> Patch applied, thanks Chrisophe.
>
> I cannot see any legitimate reason to ignore errors returned here, as
> an error would mean a partial read back of the data to the caller.

Sorry I was on vacation and missed this earlier.  The reason we don't
check for errors in the 2nd part is that the 2nd page may not be
present on some eeproms.

But I think the patch is fine because we return the proper length in
.get_module_info().  So we will now return error only if the user
specifies an invalid length, which is fine.  Thanks.

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

end of thread, other threads:[~2017-11-28 17:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-21 19:46 [PATCH] bnxt_en: Fix an error handling path in 'bnxt_get_module_eeprom()' Christophe JAILLET
2017-11-23 17:31 ` David Miller
2017-11-28 15:56 ` David Miller
2017-11-28 17:11   ` Michael Chan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).