netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tobias Waldekranz <tobias@waldekranz.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: davem@davemloft.net, kuba@kernel.org, andrew@lunn.ch,
	f.fainelli@gmail.com, netdev@vger.kernel.org
Subject: Re: [PATCH v2 net-next 3/6] net: dsa: mv88e6xxx: Fix mv88e6352_serdes_get_stats error path
Date: Tue, 05 Dec 2023 22:13:12 +0100	[thread overview]
Message-ID: <871qc09wuv.fsf@waldekranz.com> (raw)
In-Reply-To: <20231205175040.mbpepmbtxjkrb4dq@skbuf>

On tis, dec 05, 2023 at 19:50, Vladimir Oltean <vladimir.oltean@nxp.com> wrote:
> On Tue, Dec 05, 2023 at 05:04:15PM +0100, Tobias Waldekranz wrote:
>> mv88e6xxx_get_stats, which collects stats from various sources,
>> expects all callees to return the number of stats read. If an error
>> occurs, 0 should be returned.
>> 
>> Prevent future mishaps of this kind by updating the return type to
>> reflect this contract.
>> 
>> Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
>> ---
>> diff --git a/drivers/net/dsa/mv88e6xxx/serdes.c b/drivers/net/dsa/mv88e6xxx/serdes.c
>> index 3b4b42651fa3..01ea53940786 100644
>> --- a/drivers/net/dsa/mv88e6xxx/serdes.c
>> +++ b/drivers/net/dsa/mv88e6xxx/serdes.c
>> @@ -187,7 +187,7 @@ int mv88e6352_serdes_get_stats(struct mv88e6xxx_chip *chip, int port,
>>  
>>  	err = mv88e6352_g2_scratch_port_has_serdes(chip, port);
>>  	if (err <= 0)
>> -		return err;
>> +		return 0;
>
> Ok, you're saying we don't care enough about handling the catastrophic
> event where an MDIO access error takes place in mv88e6xxx_g2_scratch_read()
> to submit this to "stable".

It just felt like one of those theoretical bugs that, if you were to hit
it, you most likely have way bigger issues than not getting at your
SERDES counters; and since, as you say...

> I guess the impact in such a case is that the error (interpreted as negative
> count) makes us go back by -EIO (5) entries or whatever into the "data"
> array provided to user space, overwriting some previous stats and making
> everything after the failed counter minus the error code be reported in
> the wrong place relative to its string. I don't think that the error
> codes are high enough to overcome the ~60 port stats and cause memory
> accesses behind the "data" array.

...the potential for data corruption seems low. But I could send a v3
and split this into one change that only fixes the return value (which
could go into -net), and another one that changes the type. Do you think
it's worth it?

  reply	other threads:[~2023-12-05 21:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05 16:04 [PATCH v2 net-next 0/6] net: dsa: mv88e6xxx: Add "eth-mac" and "rmon" counter group support Tobias Waldekranz
2023-12-05 16:04 ` [PATCH v2 net-next 1/6] net: dsa: mv88e6xxx: Push locking into stats snapshotting Tobias Waldekranz
2023-12-05 17:13   ` Vladimir Oltean
2023-12-05 16:04 ` [PATCH v2 net-next 2/6] net: dsa: mv88e6xxx: Create API to read a single stat counter Tobias Waldekranz
2023-12-05 17:26   ` Vladimir Oltean
2023-12-05 16:04 ` [PATCH v2 net-next 3/6] net: dsa: mv88e6xxx: Fix mv88e6352_serdes_get_stats error path Tobias Waldekranz
2023-12-05 17:50   ` Vladimir Oltean
2023-12-05 21:13     ` Tobias Waldekranz [this message]
2023-12-05 22:38       ` Vladimir Oltean
2023-12-05 16:04 ` [PATCH v2 net-next 4/6] net: dsa: mv88e6xxx: Give each hw stat an ID Tobias Waldekranz
2023-12-05 17:51   ` Vladimir Oltean
2023-12-05 16:04 ` [PATCH v2 net-next 5/6] net: dsa: mv88e6xxx: Add "eth-mac" counter group support Tobias Waldekranz
2023-12-05 18:07   ` Vladimir Oltean
2023-12-05 21:24     ` Tobias Waldekranz
2023-12-05 16:04 ` [PATCH v2 net-next 6/6] net: dsa: mv88e6xxx: Add "rmon" " Tobias Waldekranz
2023-12-05 18:11   ` Vladimir Oltean
2023-12-06  0:22   ` Vladimir Oltean
2023-12-06  8:27     ` Tobias Waldekranz
2023-12-06 19:55       ` Vladimir Oltean
2023-12-07  9:47         ` Tobias Waldekranz

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=871qc09wuv.fsf@waldekranz.com \
    --to=tobias@waldekranz.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vladimir.oltean@nxp.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;
as well as URLs for NNTP newsgroup(s).