From: Andrew Lunn <andrew@lunn.ch>
To: Egil Hjelmeland <privat@egil-hjelmeland.no>
Cc: Juergen Borleis <jbe@pengutronix.de>,
kernel@pengutronix.de, vivien.didelot@savoirfairelinux.com,
f.fainelli@gmail.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 net-next 2/3] net: dsa: lan9303: define LAN9303_NUM_PORTS 3
Date: Tue, 1 Aug 2017 15:27:28 +0200 [thread overview]
Message-ID: <20170801132728.GA23157@lunn.ch> (raw)
In-Reply-To: <10b6b9fc-d2f9-1761-802f-724d9f6b3df1@egil-hjelmeland.no>
On Tue, Aug 01, 2017 at 02:31:44PM +0200, Egil Hjelmeland wrote:
> On 01. aug. 2017 13:49, Juergen Borleis wrote:
> >Hi Egil,
> >
> >On Tuesday 01 August 2017 13:14:38 Egil Hjelmeland wrote:
> >>Will be used instead of '3' in upcomming patches.
> >>
> >>
> >>+#define LAN9303_NUM_PORTS 3
> >>+
> >
> >Maybe we should put this macro into a shared location because
> >in "net/dsa/tag_lan9303.c" there is already a "#define LAN9303_MAX_PORTS
> >3".
> >
> >jb
> >
>
> Is there any suitable shared location for such driver specific
> definitions?
> I could change the name to LAN9303_MAX_PORTS so it the same.
> Rhymes better with DSA_MAX_PORTS too.
Hi Egil, Juergen
The other tag drivers do:
if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
return NULL;
or just
if (!ds->ports[port].netdev)
return NULL;
The first version is the safest, since a malicious switch could return
port 42, and you are accessing way off the end of ds->ports[]. It does
however require you call dsa_switch_alloc() with the correct number of
ports.
Andrew
next prev parent reply other threads:[~2017-08-01 13:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-01 11:14 [PATCH v2 net-next 0/3] Refactor lan9303_xxx_packet_processing Egil Hjelmeland
2017-08-01 11:14 ` [PATCH v2 net-next 1/3] net: dsa: lan9303: Refactor lan9303_xxx_packet_processing() Egil Hjelmeland
2017-08-01 13:39 ` Andrew Lunn
2017-08-01 13:50 ` Egil Hjelmeland
2017-08-01 14:02 ` Andrew Lunn
2017-08-01 14:43 ` Egil Hjelmeland
2017-08-01 11:14 ` [PATCH v2 net-next 2/3] net: dsa: lan9303: define LAN9303_NUM_PORTS 3 Egil Hjelmeland
2017-08-01 11:49 ` Juergen Borleis
2017-08-01 12:31 ` Egil Hjelmeland
2017-08-01 13:27 ` Andrew Lunn [this message]
2017-08-01 13:45 ` Egil Hjelmeland
2017-08-03 9:53 ` Egil Hjelmeland
2017-08-03 13:33 ` Andrew Lunn
2017-08-01 11:14 ` [PATCH v2 net-next 3/3] net: dsa: lan9303: Simplify lan9303_xxx_packet_processing() usage Egil Hjelmeland
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=20170801132728.GA23157@lunn.ch \
--to=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--cc=jbe@pengutronix.de \
--cc=kernel@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=privat@egil-hjelmeland.no \
--cc=vivien.didelot@savoirfairelinux.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.