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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 21 Jun 2021 18:51:57 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     Colin Ian King <colin.king@...onical.com>
Cc:     Qing Zhang <zhangqing@...ngson.cn>,
        Jiaxun Yang <jiaxun.yang@...goat.com>,
        Giuseppe Cavallaro <peppe.cavallaro@...com>,
        Alexandre Torgue <alexandre.torgue@...s.st.com>,
        Jose Abreu <joabreu@...opsys.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: stmmac: pci: Add dwmac support for Loongson

On Mon, Jun 21, 2021 at 04:51:28PM +0100, Colin Ian King wrote:
> Hi,
> 
> Static analysis by Coverity on today's linux-next has found an issue in
> function loongson_dwmac_probe with the following commit:
> 
> commit 30bba69d7db40e732d6c0aa6d4890c60d717e314
> Author: Qing Zhang <zhangqing@...ngson.cn>
> Date:   Fri Jun 18 10:53:34 2021 +0800
> 
>     stmmac: pci: Add dwmac support for Loongson
> 
> The analysis is as follows:
> 
> 110        plat->phy_interface = device_get_phy_mode(&pdev->dev);
> 
> Enum compared against 0
> (NO_EFFECT)
> unsigned_compare: This less-than-zero comparison of an
> unsigned value is never true. plat->phy_interface < 0U.
> 
> 111        if (plat->phy_interface < 0)
> 112                dev_err(&pdev->dev, "phy_mode not found\n");
> 
> Enum plat->phy_interface is unsigned, so can't be negative and so the
> comparison will always be false.
> 
> A possible fix is to use int variable ret for the assignment and check:
> 
> 
>         ret = device_get_phy_mode(&pdev->dev);
>         if (ret < 0)
>                 dev_err(&pdev->dev, "phy_mode not found\n");
>         plat->phy_interface = ret;
> 
> ..however, I think the dev_err may need handling too, e.g.
> 
>         ret = device_get_phy_mode(&pdev->dev);
>         if (ret < 0) {
>                 dev_err(&pdev->dev, "phy_mode not found\n");
> 		ret = -ENODEV;
> 		goto cleanup;		/* needs to be written */
> 	}
>         plat->phy_interface = ret;

Potentially a cleaner fix is to use of_get_phy_mode(), which separates
the success/error value from the phy_interface_t.

    Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ