Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1701064

Re: [PATCH v2 net-next 2/3] net: dsa: lan9303: define LAN9303_NUM_PORTS 3

From Egil Hjelmeland <privat@egil-hjelmeland.no>
Newsgroups linux.kernel
Subject Re: [PATCH v2 net-next 2/3] net: dsa: lan9303: define LAN9303_NUM_PORTS 3
Date 2017-08-01 15:50 +0200
Message-ID <u9FIC-4Dg-9@gated-at.bofh.it> (permalink)
References <u9Dnr-3jr-1@gated-at.bofh.it> <u9Dns-3jr-13@gated-at.bofh.it> <u9E09-3xA-13@gated-at.bofh.it> <u9ECR-40W-11@gated-at.bofh.it> <u9Fpf-4wG-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 01. aug. 2017 15:27, Andrew Lunn wrote:
> 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.
> 

Sounds like a plan for a later patch, when changing to 
dsa_switch_alloc(LAN9303_NUM_PORTS)


>       Andrew
> 

Egil

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 net-next 0/3] Refactor lan9303_xxx_packet_processing Egil Hjelmeland <privat@egil-hjelmeland.no> - 2017-08-01 13:20 +0200
  [PATCH v2 net-next 2/3] net: dsa: lan9303: define LAN9303_NUM_PORTS 3 Egil Hjelmeland <privat@egil-hjelmeland.no> - 2017-08-01 13:20 +0200
    Re: [PATCH v2 net-next 2/3] net: dsa: lan9303: define LAN9303_NUM_PORTS 3 Juergen Borleis <jbe@pengutronix.de> - 2017-08-01 14:00 +0200
      Re: [PATCH v2 net-next 2/3] net: dsa: lan9303: define  LAN9303_NUM_PORTS 3 Egil Hjelmeland <privat@egil-hjelmeland.no> - 2017-08-01 14:40 +0200
        Re: [PATCH v2 net-next 2/3] net: dsa: lan9303: define  LAN9303_NUM_PORTS 3 Andrew Lunn <andrew@lunn.ch> - 2017-08-01 15:30 +0200
          Re: [PATCH v2 net-next 2/3] net: dsa: lan9303: define  LAN9303_NUM_PORTS 3 Egil Hjelmeland <privat@egil-hjelmeland.no> - 2017-08-01 15:50 +0200
          Re: [PATCH v2 net-next 2/3] net: dsa: lan9303: define  LAN9303_NUM_PORTS 3 Egil Hjelmeland <privat@egil-hjelmeland.no> - 2017-08-03 12:00 +0200
            Re: [PATCH v2 net-next 2/3] net: dsa: lan9303: define  LAN9303_NUM_PORTS 3 Andrew Lunn <andrew@lunn.ch> - 2017-08-03 15:40 +0200
  [PATCH v2 net-next 3/3] net: dsa: lan9303: Simplify lan9303_xxx_packet_processing() usage Egil Hjelmeland <privat@egil-hjelmeland.no> - 2017-08-01 13:20 +0200
  [PATCH v2 net-next 1/3] net: dsa: lan9303: Refactor lan9303_xxx_packet_processing() Egil Hjelmeland <privat@egil-hjelmeland.no> - 2017-08-01 13:20 +0200
    Re: [PATCH v2 net-next 1/3] net: dsa: lan9303: Refactor  lan9303_xxx_packet_processing() Andrew Lunn <andrew@lunn.ch> - 2017-08-01 15:50 +0200
      Re: [PATCH v2 net-next 1/3] net: dsa: lan9303: Refactor  lan9303_xxx_packet_processing() Egil Hjelmeland <privat@egil-hjelmeland.no> - 2017-08-01 16:00 +0200
        Re: [PATCH v2 net-next 1/3] net: dsa: lan9303: Refactor  lan9303_xxx_packet_processing() Andrew Lunn <andrew@lunn.ch> - 2017-08-01 16:10 +0200
          Re: [PATCH v2 net-next 1/3] net: dsa: lan9303: Refactor  lan9303_xxx_packet_processing() Egil Hjelmeland <privat@egil-hjelmeland.no> - 2017-08-01 16:50 +0200

csiph-web