Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp27882lqb; Thu, 14 Mar 2024 04:44:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVrq1369s+OE7XachtErZhA33n0vNIeIzNDQfrslxLeQpIjge8EFG9NgUmw7puKELhDVbqGIXhGQMdYWIWJvZpJ7gPP4eAnc0hmpgnjdw== X-Google-Smtp-Source: AGHT+IGY85XI/6dyQ0iip/RD4comDBHspeTj996c57PGG7sFQMbirCokzokc687Cv8Y74RB6VeXp X-Received: by 2002:a05:6122:702:b0:4d3:43f8:8541 with SMTP id 2-20020a056122070200b004d343f88541mr1565095vki.1.1710416658957; Thu, 14 Mar 2024 04:44:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710416658; cv=pass; d=google.com; s=arc-20160816; b=nCyE2uSE0hp5xsZZ1jHjXG0tm3Q7suyCDMgAS/ihJiCZh8xxuz1iXyjKmAtdD2xrDU QS+wKBmcrgD1gf3pmhfgAjsHSPywZC74kkb5c5QahBlWSFnEgiFvivUk5egEzyXir9BY hvA9dpuZGsruOnIWhiIjMbGAuqJ9tN2rwkmQ81YzyD9DDxpcCWZL5VSyji/zjN8e/M1y Bkas7W60rQV9cQbdjpU/RMn+BiHBqMJuOLeEB0QpdTxGLnaR4qA/zJdqlpc/2Wzn6qHl WA0+oHgjyjGjKfcjan6vrBruzpmTJ3WR6eONnNi4yteCC5pbXgTrY/nZKgq8t6NqSV0I Nt4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:cc:to:content-language :references:subject:from:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=H/ZK65jVzIQZcO7Mtx8NnZZOQ6orfT0ALeEdN5PzJNY=; fh=iZ3ojOIgSm5HnbsdtdKqh+Ro63iRTj9noixICz2wrH0=; b=ANSU3QFPdlICrdkZkjox5PXGq+WtW98lzuLcWx03Y05r84hii2bRUeg5fPayclOuAX rvtZ7/v7EzVdRLx6ai+qyPUkEA8E0JlRFJb2VFoOQS4o9K4tFujupxc4UvyRkSGq7y46 mrTrqLTdcU0uxIF3/68SyxJ/aRX/N94+JapUE7sE4sxw6Z3g33R7goO7+dnZ9jbchQVk oPTUzktFi1INnkqDAfcPs82AFxwcPt3k5+pJsNLmck/6NDJ7GHUq+P7mJuPj2m918K3z Lw5IxC8dF8lZeaZLPcmvOyUczHQgox9M8WOCsnVlB0RkNuXAtcHVN8YSSK5EgTUVTpdG TjlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=ancud.ru); spf=pass (google.com: domain of linux-kernel+bounces-103187-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103187-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 2-20020a0562140cc200b00690011ff09csi489756qvx.393.2024.03.14.04.44.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 04:44:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103187-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=ancud.ru); spf=pass (google.com: domain of linux-kernel+bounces-103187-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103187-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A92901C22568 for ; Thu, 14 Mar 2024 11:44:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 585486F06A; Thu, 14 Mar 2024 11:44:08 +0000 (UTC) Received: from relay163.nicmail.ru (relay163.nicmail.ru [91.189.117.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2214617588; Thu, 14 Mar 2024 11:44:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.189.117.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710416647; cv=none; b=gCk79OL53kcL+NRC1DNXwyfmFLZQh16hZNYxZaq/0fFskbwUJtq06je2eKX5ofoU2Kh5eNcaf2wYkpp9C0Y3ulJl+DQ0jJqVgKjNBIb3sXsvg6NG7XrT2uUM2rVSaP2hEB9dlR9yjuZiILXMgV3hWA/lK6B+yD6YI3wesrI9KBU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710416647; c=relaxed/simple; bh=vCqx9xc2aCUVJ6wl9bag1zhUxchc7u8nmzyYAREAqNY=; h=Message-ID:Date:MIME-Version:From:Subject:References:To:Cc: In-Reply-To:Content-Type; b=Z3TMcqu0+Xr7KdjKF1c9oxNmCrjfZLwISIeW027Pfmf8kwDupBk6eFZ+c6FMHpw3evoI7oLR3qYRJWZWRiqNTV+D8nFLRCQdEUYVNfVeugd1gxp6T87pZuBIP6rKSBLAyWtIYtKFoeep8uw35YfMQfn9V9gZ9glwIG3jJybh+GU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ancud.ru; spf=pass smtp.mailfrom=ancud.ru; arc=none smtp.client-ip=91.189.117.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ancud.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ancud.ru Received: from [10.28.138.149] (port=30558 helo=[192.168.95.111]) by relay.hosting.mail.nic.ru with esmtp (Exim 5.55) (envelope-from ) id 1rkj3j-00077G-Ba; Thu, 14 Mar 2024 14:15:40 +0300 Received: from [87.245.155.195] (account kiryushin@ancud.ru HELO [192.168.95.111]) by incarp1102.mail.hosting.nic.ru (Exim 5.55) with id 1rkj3j-006bkS-1f; Thu, 14 Mar 2024 14:15:39 +0300 Message-ID: <031a0fe6-79dc-464b-b8d9-946f75971378@ancud.ru> Date: Thu, 14 Mar 2024 14:15:37 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Nikita Kiryushin Subject: [PATCH net] net: phy: fix phy_read_poll_timeout argument type in genphy_loopback References: <> Content-Language: en-US To: Andrew Lunn Cc: Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Oleksij Rempel , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org In-Reply-To: <> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-MS-Exchange-Organization-SCL: -1 read_poll_timeout inside phy_read_poll_timeout can set val negative in some cases (for example, __mdiobus_read inside phy_read can return -EOPNOTSUPP). Supposedly, commit 4ec732951702 ("net: phylib: fix phy_read*_poll_timeout()") should fix problems with wrong-signed vals, but I do not see how as val is sent to phy_read as is and __val = phy_read (not val) is checked for sign. Change val type for signed to allow better error handling as done in other phy_read_poll_timeout callers. This will not fix any error handling by itself, but allows, for example, to modify cond with appropriate sign check or check resulting val separately. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 014068dcb5b1 ("net: phy: genphy_loopback: add link speed configuration") Signed-off-by: Nikita Kiryushin --- drivers/net/phy/phy_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 8297ef681bf5..6c6ec9475709 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2831,8 +2831,8 @@ EXPORT_SYMBOL(genphy_resume); int genphy_loopback(struct phy_device *phydev, bool enable) { if (enable) { - u16 val, ctl = BMCR_LOOPBACK; - int ret; + u16 ctl = BMCR_LOOPBACK; + int ret, val; ctl |= mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); -- 2.34.1