netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vivien Didelot <vivien.didelot@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, "Marek Behún" <marek.behun@nic.cz>,
	f.fainelli@gmail.com, andrew@lunn.ch,
	"Vivien Didelot" <vivien.didelot@gmail.com>
Subject: [PATCH net-next 01/10] net: dsa: mv88e6xxx: check errors in mv88e6352_serdes_irq_link
Date: Sat, 31 Aug 2019 16:18:27 -0400	[thread overview]
Message-ID: <20190831201836.19957-2-vivien.didelot@gmail.com> (raw)
In-Reply-To: <20190831201836.19957-1-vivien.didelot@gmail.com>

The mv88e6352_serdes_irq_link helper is not checking for any error that
may occur during hardware accesses. Worst, the "up" boolean is set from
the potentially unused "status" variable, if read operations failed.

As done in mv88e6390_serdes_irq_link_sgmii, return right away and do
not call dsa_port_phylink_mac_change if an error occurred.

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
---
 drivers/net/dsa/mv88e6xxx/serdes.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/serdes.c b/drivers/net/dsa/mv88e6xxx/serdes.c
index 38c0da2492c0..7eb7ed68c91d 100644
--- a/drivers/net/dsa/mv88e6xxx/serdes.c
+++ b/drivers/net/dsa/mv88e6xxx/serdes.c
@@ -186,14 +186,19 @@ static void mv88e6352_serdes_irq_link(struct mv88e6xxx_chip *chip, int port)
 	struct dsa_switch *ds = chip->ds;
 	u16 status;
 	bool up;
+	int err;
 
-	mv88e6352_serdes_read(chip, MII_BMSR, &status);
+	err = mv88e6352_serdes_read(chip, MII_BMSR, &status);
+	if (err)
+		return;
 
 	/* Status must be read twice in order to give the current link
 	 * status. Otherwise the change in link status since the last
 	 * read of the register is returned.
 	 */
-	mv88e6352_serdes_read(chip, MII_BMSR, &status);
+	err = mv88e6352_serdes_read(chip, MII_BMSR, &status);
+	if (err)
+		return;
 
 	up = status & BMSR_LSTATUS;
 
-- 
2.23.0


  reply	other threads:[~2019-08-31 20:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-31 20:18 [PATCH net-next 00/10] net: dsa: mv88e6xxx: centralize SERDES IRQ handling Vivien Didelot
2019-08-31 20:18 ` Vivien Didelot [this message]
2019-08-31 20:18 ` [PATCH net-next 02/10] net: dsa: mv88e6xxx: fix SERDES IRQ mapping Vivien Didelot
2019-08-31 20:18 ` [PATCH net-next 03/10] net: dsa: mv88e6xxx: introduce .serdes_irq_mapping Vivien Didelot
2019-08-31 20:18 ` [PATCH net-next 04/10] net: dsa: mv88e6xxx: simplify .serdes_get_lane Vivien Didelot
2019-08-31 20:18 ` [PATCH net-next 05/10] net: dsa: mv88e6xxx: implement mv88e6352_serdes_get_lane Vivien Didelot
2019-08-31 20:18 ` [PATCH net-next 06/10] net: dsa: mv88e6xxx: merge mv88e6352_serdes_power_set Vivien Didelot
2019-08-31 20:18 ` [PATCH net-next 07/10] net: dsa: mv88e6xxx: pass lane to .serdes_power Vivien Didelot
2019-08-31 20:18 ` [PATCH net-next 08/10] net: dsa: mv88e6xxx: introduce .serdes_irq_enable Vivien Didelot
2019-08-31 20:18 ` [PATCH net-next 09/10] net: dsa: mv88e6xxx: introduce .serdes_irq_status Vivien Didelot
2019-08-31 20:18 ` [PATCH net-next 10/10] net: dsa: mv88e6xxx: centralize SERDES IRQ handling Vivien Didelot
2019-09-01 19:25 ` [PATCH net-next 00/10] " David Miller

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=20190831201836.19957-2-vivien.didelot@gmail.com \
    --to=vivien.didelot@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=marek.behun@nic.cz \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).