Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp954978lqb; Fri, 15 Mar 2024 10:52:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXeIfUx7Nod6ho4DX/VfP3bSiXled0O8NlL6JGogfdm08yagmZVg5uzqZ59gIkp8jlSJTcyvbLbo/2NVZq7UnFXlNUvH8eVvv0gyda3Ug== X-Google-Smtp-Source: AGHT+IFegenOu7j1Ybx+qTdDXR0qr9IZD0xh0VvYY9cfg1Iz0tRgYczWhw1XkCiiZa2UortP/qUl X-Received: by 2002:a17:906:53d1:b0:a46:47bc:580b with SMTP id p17-20020a17090653d100b00a4647bc580bmr4131961ejo.56.1710525138655; Fri, 15 Mar 2024 10:52:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710525138; cv=pass; d=google.com; s=arc-20160816; b=ZnI8LmOxPfpwUjgQoWZGVWeJe7yVH20mP/NhpPRkiY8YjnbxkZse+vKoepz2reI7PW hCMgwYXha4nfF4+Hhben1oC2BHNdvWYH12HPaTsGzGd2Dw4CWcyly4ltShRkRaiyVSJ6 ILiH5jBkvQS+zVtKur6Ux1wAgAiLJRBilLd7IR1oRaJOKpah7cUg+ZHUJWtD6vPntcFI o/XxG+/Qv0RV8a+LMRIEQHJDivs00FofF4G6wjF9NotM4UCCrjadHxX2ZTjXx7QtvbGe 6+RMSCJIaXDNY3UqOA3cmOVykSNZuOjGItKGtB8PR8yFxlITy43WdWLMDFPs0MbmA0f8 o2gg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=I3dtRwCEucE4+r6SMjVS3NaV0oSqyc4ml6s32hNmY/A=; fh=DQaStIt67/wDIqEjGYya0QFWlbkO/6CTaFU3zdgEo3Y=; b=W2Ru8CGhldw09u/jYUK9i57dRuD1M26RVgr7OEC1GnkiYd0dJ8ztNim4AXpX7La89J Xy9ovkyfW1fW8n5Gj5gZxMO9m1kz7vfz9o2gIy0pTF4eLVS8dch2SRVQbuZOBB1lnBiH CHWb4OeDCchonq/l4IKoTvAqtvuLOzyc2eEkQ/McWpz68NV0+5hVgR7bQtSyoiliSQIQ ZAQB+PFlfrfpMZkUa/CKJxP2aF4AqmUxxwi4MJoR95vnaMOrZDE/V5X4V81KK5y+Cv4w YKbR0YiV+PiF2GznGykWoTj/STMpr7GDzsJ/gT+zX3S48kP5L1XpYZUTNmCUSDSiJ2wm w7Qw==; 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-104753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104753-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lf12-20020a170907174c00b00a4642a02ccesi1849236ejc.840.2024.03.15.10.52.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 10:52:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=ancud.ru); spf=pass (google.com: domain of linux-kernel+bounces-104753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104753-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5F3611F2415C for ; Fri, 15 Mar 2024 17:52:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E59A74F211; Fri, 15 Mar 2024 17:51:57 +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 270E44DA08; Fri, 15 Mar 2024 17:51:52 +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=1710525117; cv=none; b=ACfJvXF+YEQu+ev/wHcvS+qMAsCgGP13qZ+wd/YrnrIEkU2v1+1+nlK5WcjndqS9xq/ZbPym0UhJW82nCw+Gcj3mOPRiEZtdNUrN6xBrXUMbMqeaSbt91y8yiiu4rXIKqHUnhYqMA4oNlmM8SgOICw6qhl6DYtfSRTafToVutb0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710525117; c=relaxed/simple; bh=kB7dpmBv6Z1afxF2sKPJV10+Ol3WrAzuMADcOyDjF9U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kBvPfomhvIeBNM0OTmsoG7htUP81XuZ/E52hnIphIaumgy+KTJgA6CpqJRpSZXNRNKq2SiPWJmU/aAmRcTey5Iy4a6zh6x2eGo3mpfqtNCE0JfwQxnssh49wjmjJHfcGlHwJ91O6wNUd3bwH4H2tnDWfxfqrLyZA1I89Dqm0+9Y= 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.136.255] (port=45346 helo=mitx-gfx..) by relay.hosting.mail.nic.ru with esmtp (Exim 5.55) (envelope-from ) id 1rlBiT-0002BV-A6; Fri, 15 Mar 2024 20:51:37 +0300 Received: from [87.245.155.195] (account kiryushin@ancud.ru HELO mitx-gfx..) by incarp1105.mail.hosting.nic.ru (Exim 5.55) with id 1rlBiT-0002Zm-05; Fri, 15 Mar 2024 20:51:37 +0300 From: Nikita Kiryushin To: Andrew Lunn Cc: Nikita Kiryushin , 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 Subject: [PATCH net] net: phy: fix phy_read_poll_timeout argument type in genphy_loopback Date: Fri, 15 Mar 2024 20:50:52 +0300 Message-Id: <20240315175052.8049-1-kiryushin@ancud.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240314164826.161bd398@kernel.org> References: <20240314164826.161bd398@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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