All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Birger Koblitz" <mail@birger-koblitz.de>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH net-next v19 04/13] ax88179_178a: Add HW support for AX179A-based chips
Date: Sun, 11 Oct 2026 04:54:53 +0000	[thread overview]
Message-ID: <sashiko-outbox-167010@kernel.org> (raw)
In-Reply-To: <20261010-ax88179a-v19-4-7475173cfb56@birger-koblitz.de>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] net: ax88179a: perm_addr overwritten by dev_addr on interface up
- [Low] net/usb: unaligned memory access via cast of u8 buf[5]
--

commit 8f7d8eac10e2d0c51938d5773370c574a2391e9a
Author: Birger Koblitz <mail@birger-koblitz.de>

ax88179_178a: Add HW support for AX179A-based chips

This commit adds bindings and hardware support for AX179A-based USB-Ethernet
controllers. It introduces a vendor mode switch for CDC-NCM fallback, adds
new device entries, and provides hardware-specific initialization sequences
via ax88179a_devices.c.

> diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/net/usb/ax88179a_devices.c
[ ... ]
> +static int ax88179a_reset(struct usbnet *dev)
> +{
> +	struct ax88179_data *ax179_data = dev->driver_priv;
> +	u16 *tmp16;
> +	u8 buf[5];
> +	u16 rxctl;
> +	u8 *tmp;
> +
> +	tmp16 = (u16 *)buf;
> +	tmp = (u8 *)buf;
[ ... ]
> +	ax88179_write_u8(dev, AX_ACCESS_MAC, AX88179A_MAC_ARC_CTRL, 1, 0);
> +	ax88179_write_u8(dev, AX_ACCESS_MAC, AX88179A_MAC_SWP_CTRL, 1, 0);
> +	ax88179_write_u8(dev, AX_ACCESS_MAC, AX88179A_MAC_TX_HDR_CKSUM, 1, 0);
> +
> +	/* Read MAC address from DTB or asix chip */
> +	ax88179_get_mac_addr(dev);
> +	memcpy(dev->net->perm_addr, dev->net->dev_addr, ETH_ALEN);

[Severity: Medium]
Is it safe to unconditionally overwrite the permanent MAC address during an
interface reset?

During routine interface resets (e.g., bringing the interface up via
usbnet_open()), the usbnet framework calls the driver's .reset callback,
which points to ax88179a_reset().

If a user changes the MAC address while the interface is down, that custom
address is correctly written to the hardware. However, when the interface
comes back up, ax88179_get_mac_addr() reads that temporary custom MAC back
from the hardware and copies it into dev->net->perm_addr.

Does this permanently clobber the immutable perm_addr with the user's
temporary MAC address and break tools like ethtool -P?

[ ... ]
> +	if (ax179_data->chip_version < AX_VERSION_AX88179A)
> +		*tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL | AX_MONITOR_MODE_RWMP;
> +	else
> +		*tmp = AX_MONITOR_MODE_RWMP;
> +	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, tmp);
> +
> +	/* Configure default medium type => giga */
> +	*tmp16 = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN |
> +		 AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_FULL_DUPLEX;
> +	if (!ax179_data->is_ax88772d)
> +		*tmp16 |= AX_MEDIUM_GIGAMODE;
> +	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, tmp16);

[Severity: Low]
Does assigning to *tmp16 cause an unaligned memory access here?

The stack buffer u8 buf[5] has a natural alignment of 1 byte. Casting it to
u16 *tmp16 and directly assigning a 16-bit value violates C standard
aliasing and alignment rules. On architectures lacking hardware support for
unaligned accesses, this causes alignment faults.

Since this patch introduces the ax88179_write_u16() helper, could that be
used instead to avoid the unaligned cast entirely?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261010-ax88179a-v19-0-7475173cfb56@birger-koblitz.de?part=4

  reply	other threads:[~2026-10-11  4:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10  4:54 [PATCH net-next v19 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
2026-10-10  4:54 ` [PATCH net-next v19 01/13] phylink: Add phylink_mac_interrupt Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-11  5:32     ` Birger Koblitz
2026-10-10  4:54 ` [PATCH net-next v19 02/13] phylib: Add support for PHYs with broken forced mode Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 03/13] ax88179_178a: Split driver into library and device specific code Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 04/13] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
2026-10-11  4:54   ` sashiko-bot [this message]
2026-10-10  4:54 ` [PATCH net-next v19 05/13] ax88179_178a: Add EEE configuration support for AX88179A MACs Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 06/13] ax88179_178a: Add EEE configuration support for AX88179A PHYs Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 07/13] ax88179_178a: Add VLAN offload support for AX88179A Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 08/13] ax88179_178a: Add AX179A/AX279 multicast configuration Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 09/13] ax88179_178a: Add Suspend/resume support for AX88179A/772D/279 Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 10/13] ax88179_178a: Add ethtool get_drvinfo Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 11/13] ax88179_178a: Update driver name and information Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 12/13] ax88179_178a: Add support for AX88179A/772D/279 EEPROM access Birger Koblitz
2026-10-11  4:55   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
2026-10-11  4:55   ` sashiko-bot
2026-10-10  6:20 ` [PATCH v19 0/13] ax88179_178a: Add support for AX88179A-based chips Jianhui Xu
2026-10-10  7:42   ` Birger Koblitz

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=sashiko-outbox-167010@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mail@birger-koblitz.de \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.