Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3894816pxj; Mon, 21 Jun 2021 08:52:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb2EJRTaZkxWb2IHNjUmwOBEAfqu4PPnOBexEWEIwsTKKPX4Tc+SZACOEzNkdOMlsXwd6v X-Received: by 2002:a92:da88:: with SMTP id u8mr7010404iln.185.1624290772604; Mon, 21 Jun 2021 08:52:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624290772; cv=none; d=google.com; s=arc-20160816; b=SvH5wRPI+okF4o2AF5ZFxMEV/TU47fpzGhcMUrlPi2/dK+YRSTHGZF9T/uwWHlxDoE h9OkQ3rt9TCNkSwUZv1WpCzhrAGxsegw13zrPxrY2Er+Rravtzbl1B4yV4jNOFgCPt9b 19Qz0Lh3cuKkwkJfcrHW9mCtVnjrNfipl/ntnqWIOOV2Uiul55/Bah1y5CHyZw2uuyE6 /pcvc+Dv6v3PbNNiaUlcEE+RZUbhWEAwnf0v9Bdx2isCRlfWLRnU52Z+eE3Bb3h8MZ1W 1hTG+kdthyYmMvkK37CyeGXOVUjCZXQ1Wv1e6Cnv4i6tK6800OohVy+gXAYj9S9Fhwea tr8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:user-agent:date:message-id:subject:cc:to:from; bh=yRlPbE72KbKa1Ct2oBtzBxPKOebZiUbeePE/x6cxuD0=; b=cd2INFquDFXZQkQdXAnT1UmbC3NE+TJ92Tmlef1DVvF+mLAtIQECBoFRUetpU0IHHB 2bEDqWD1RjfsMPOzVd3hMfY7vQ/g/gYNoXBgE8RmZFPkH2Xfh4XQJFYXj0E8OHKlT4ID Vb11TIhmT7bF6mYB8l4CugvxWT6dYMa9/LTQHs1ArR38aRn7qChIhhN4RX+tFjkYv/Eh o5VfPbNdno+6w/fAJmpK/cyEjvZcLnA31fPb4nUu1GxlXXlMtoD5PshSTCW2e9Ml91Ls 7F+NyVboB+8WFpP0bC3/8PRgUzcL30i7pGhfXs1ujpuI6wNE0Lk2R6CS0mM4LKJig1Vr u7Vg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h2si2113338ilh.91.2021.06.21.08.52.40; Mon, 21 Jun 2021 08:52:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230161AbhFUPxt (ORCPT + 99 others); Mon, 21 Jun 2021 11:53:49 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:51645 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230251AbhFUPxr (ORCPT ); Mon, 21 Jun 2021 11:53:47 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212]) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lvMCv-0003rJ-FK; Mon, 21 Jun 2021 15:51:29 +0000 From: Colin Ian King To: Qing Zhang , Jiaxun Yang Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Maxime Coquelin , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: re: stmmac: pci: Add dwmac support for Loongson Message-ID: <37057fe8-f7d1-7ee0-01c7-916577526b5b@canonical.com> Date: Mon, 21 Jun 2021 16:51:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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; Colin