Re: [PATCH v3] net/can/gs_usb: increase max interface to U8_MAX
From: Celeste Liu
Date: Tue Sep 30 2025 - 02:20:04 EST
On 2025-09-30 13:44, Vincent Mailhol wrote:
> On 9/30/25 12:06 PM, Celeste Liu wrote:
>> This issue was found by Runcheng Lu when develop HSCanT USB to CAN FD
>> converter[1]. The original developers may have only 3 intefaces device to
> ^^^^^^^^^
> interfaces (missing "r")
Fixed in v4. Redundant typeof() was removed as well.
>
>> test so they write 3 here and wait for future change.
>>
>> During the HSCanT development, we actually used 4 interfaces, so the
>> limitation of 3 is not enough now. But just increase one is not
>> future-proofed. Since the channel type in gs_host_frame is u8, just
>> increase interface number limit to max size of u8 safely.
>>
>> [1]: https://github.com/cherry-embedded/HSCanT-hardware
>>
>> Fixes: d08e973a77d1 ("can: gs_usb: Added support for the GS_USB CAN devices")
>> Reported-by: Runcheng Lu <runcheng.lu@xxxxxxxxxxx>
>> Cc: stable@xxxxxxxxxxxxxxx
>> Signed-off-by: Celeste Liu <uwu@xxxxxxxxxxxxxxxxx>
>
> Reviewed-by: Vincent Mailhol <mailhol@xxxxxxxxxx>
>
> The patch is good as-is. However, speaking of the interface numbers, there is
> another issue in this gs_usb driver: net_device->dev_port is not populated, and
> according to the documentation, this is a bug.
>
>
> See the description here:
>
>
>
> https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net
>
>
>
> What: /sys/class/net/<iface>/dev_port
>
> Date: February 2014
>
> KernelVersion: 3.15
>
> Contact: netdev@xxxxxxxxxxxxxxx
>
> Description:
>
> Indicates the port number of this network device, formatted
>
> as a decimal value. Some NICs have multiple independent ports
>
> on the same PCI bus, device and function. This attribute allows
>
> userspace to distinguish the respective interfaces.
>
>
>
> Note: some device drivers started to use 'dev_id' for this
>
> purpose since long before 3.15 and have not adopted the new
>
> attribute ever since. To query the port number, some tools look
>
> exclusively at 'dev_port', while others only consult 'dev_id'.
>
> If a network device has multiple client adapter ports as
>
> described in the previous paragraph and does not set this
>
> attribute to its port number, it's a kernel bug.
>
>
>
> Would you mind sending a separate patch (with a Fixes: tag) to resolve this?
Ok. I will send a patch for it later.
>
>
> Yours sincerely,
> Vincent Mailhol
>