lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <aPsjYKQMzpY0nSXm@stanley.mountain>
Date: Fri, 24 Oct 2025 09:57:36 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: David Yang <mmyangfl@...il.com>
Cc: netdev@...r.kernel.org
Subject: [bug report] net: dsa: yt921x: Add support for Motorcomm YT921x

Hello David Yang,

Commit 186623f4aa72 ("net: dsa: yt921x: Add support for Motorcomm
YT921x") from Oct 17, 2025 (linux-next), leads to the following
Smatch static checker warning:

	drivers/net/dsa/yt921x.c:702 yt921x_read_mib()
	warn: was expecting a 64 bit value instead of '(~0)'

drivers/net/dsa/yt921x.c
    671 static int yt921x_read_mib(struct yt921x_priv *priv, int port)
    672 {
    673         struct yt921x_port *pp = &priv->ports[port];
    674         struct device *dev = to_device(priv);
    675         struct yt921x_mib *mib = &pp->mib;
    676         int res = 0;
    677 
    678         /* Reading of yt921x_port::mib is not protected by a lock and it's vain
    679          * to keep its consistency, since we have to read registers one by one
    680          * and there is no way to make a snapshot of MIB stats.
    681          *
    682          * Writing (by this function only) is and should be protected by
    683          * reg_lock.
    684          */
    685 
    686         for (size_t i = 0; i < ARRAY_SIZE(yt921x_mib_descs); i++) {
    687                 const struct yt921x_mib_desc *desc = &yt921x_mib_descs[i];
    688                 u32 reg = YT921X_MIBn_DATA0(port) + desc->offset;
    689                 u64 *valp = &((u64 *)mib)[i];
    690                 u64 val = *valp;
    691                 u32 val0;
    692                 u32 val1;
    693 
    694                 res = yt921x_reg_read(priv, reg, &val0);
    695                 if (res)
    696                         break;
    697 
    698                 if (desc->size <= 1) {
    699                         if (val < (u32)val)
    700                                 /* overflow */
    701                                 val += (u64)U32_MAX + 1;
--> 702                         val &= ~U32_MAX;

~U32_MAX is zero so this is just "val = 0;"  Perhaps the intent
was "val &= ~(u64)U32_MAX;"?

    703                         val |= val0;
    704                 } else {
    705                         res = yt921x_reg_read(priv, reg + 4, &val1);
    706                         if (res)
    707                                 break;
    708                         val = ((u64)val0 << 32) | val1;
    709                 }
    710 
    711                 WRITE_ONCE(*valp, val);
    712         }
    713 

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ