Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2613934lqp; Mon, 25 Mar 2024 04:35:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXKa++Oqt9O6S6PzWeqSWwr6tUp8UjH6sq2SYs9jniAzTt+gsuHKa3RwZEXPtynBIO+Wt/wKTUEqeFaciWzRtsvweHx0GUTSvTosqI5gA== X-Google-Smtp-Source: AGHT+IH+lKRAsRJ2QcoL2stotO7JVAPJ0nE28yBhQ9tgiHq5k7FI9GS7K/Vw8pF7nEC1k0U17cqp X-Received: by 2002:a05:6870:f699:b0:22a:1e0c:812c with SMTP id el25-20020a056870f69900b0022a1e0c812cmr5400135oab.37.1711366539502; Mon, 25 Mar 2024 04:35:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711366539; cv=pass; d=google.com; s=arc-20160816; b=Wy6ac/tSjFPjdMUMc7KnN8n4sXHhVLnv3uFwXD4b8HguFdj06WwT9yrrfxx1EifpTV AKgrlOhIpFRf7MTJo/cyxUtDq9lBwaMW2IhK2UTRbR0VV8oMV7TN0H20qrFtsy+fi+0k T8v0Teb2g6DDTbADbun6cpzJpf5LMHAVouvRFhumWlXO99XbdM5GEymcsQK6AahYWKg+ 2Bx0gyOCvIWVCCdD+dITAfQezvQ93DhgzwxhOptNVPkA6vsIlkQrRlx8TGYmyVbsPb1g Ea8gydFsb0Jaw9egpWbpFit1ZCQ6pgYqp5gy71oFtNMzKk8hKuiI0PW9KoOxqVrAQqMY XP+A== 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:dkim-signature; bh=QG9227B0CEwooFwrx3awBK68oYgnv95+lJyjs6NPiwA=; fh=akhehA9bjmhcj8OY9/y0FWK2AA+CgDdDtqKmH+H03AQ=; b=VT7zJtV+ySyNPY2GwDQtExpMM4MVkWe/dLtjqABPi8YrlDkAU/4Aw4TAnrSPn3XZhp m1dV1gQA/DFDo5Xq6/sJxkJAF16Ztwa9dA/7n9Z7OsCXqzW+ySPF6zinSwILEZd8iLns 2uZTQlsHYmIsx8ikAsCTSqAgzepvnMlxdIQ+6BapP9ucMg3JWZrSrfxv2LvhDiZXa/rz 6/Pwx5dkduIQzHnR/hS3aEn/k88ce27tlT2yn7RM6G3aCkc+OifMac1+EbPhj8zNXoCr jasmP1FU9d9c2j9cmVkxbc7JLQJXKL6rGArRwaE0IAXs3osQBTKk/BGfPiRRBg/EFm1k x0sg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="XFJSGcY/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115443-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115443-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b68-20020a62cf47000000b006ea93543065si5002937pfg.283.2024.03.25.04.35.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 04:35:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115443-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="XFJSGcY/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115443-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115443-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id F34452A61BD for ; Mon, 25 Mar 2024 10:57:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7D21214847; Mon, 25 Mar 2024 02:38:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XFJSGcY/" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2E5C1146A89; Sun, 24 Mar 2024 22:53:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320805; cv=none; b=OlOQdzTmQeOTT/+pMqAu0tFpNdJ2tGqHSmzjy2Lep2UwNngvnpHHXBgQsN2qgMlREPohZhdfdb7L5/w9QbymLbnmEEgmNTzapDb6gHdMdJuNdzR4KR7NAzSwLFD155aMta8bQcRYqO+v3FkvEELJ+7sfruNrLHrpA8dl9mrGXH4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320805; c=relaxed/simple; bh=AFtDp0I19989MUL6aaJ2DsxhejQl4XuhXqLEYgx6LVo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cet7pocx8uSYIrc+9kHs/cY8VnJOY9ZVUGDWjZWcCYbyGQMYkWZ2dc/tafO2+AAnBZl9yq/EcxNmJdH014v4aVvngCLK7w8HP+J9D/SpWv3A2YdCz+JU9aPrukKWufTIwGyZzdcKkXLvPz/l499LUdzHxE4osqwqTy/mtuI/LvM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XFJSGcY/; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E5F6C433F1; Sun, 24 Mar 2024 22:53:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320804; bh=AFtDp0I19989MUL6aaJ2DsxhejQl4XuhXqLEYgx6LVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XFJSGcY/XAlQ+aIvoCiaDzPfwIxmU8iuY9nf9hkuTe34v/aF88opMQuls+NEU4bWn 1k61S4GDYVtnoSsYzoSxKmFh9SHogJDqxcLL+VQKCM/b5S21/HMQiVcHjChWfNtgOR vf38rTM12zWpAgykc+c5jkeQJaOIkDetUjQfge0Ueh3XrelYfO4uI8Gn22DHSPYNmw GEg5TUf9SqLPBZ47nMalqIlsN2UHd5w5kX5JYXQGHAwzrEQCF3Ham2nIM3+JG6whpm e1HePYPOkmABWG1A1iRbN5Bx6W1ieaBmd2sJaNTzZ5kbBURJGjCQ30JTnerw4wF8jx VdjO9KppSF3JA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?K=C3=A9vin=20L=27h=C3=B4pital?= , Enguerrand de Ribaucourt , Russell King , "David S . Miller" , Sasha Levin Subject: [PATCH 6.7 368/713] net: phy: fix phy_get_internal_delay accessing an empty array Date: Sun, 24 Mar 2024 18:41:34 -0400 Message-ID: <20240324224720.1345309-369-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324224720.1345309-1-sashal@kernel.org> References: <20240324224720.1345309-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Kévin L'hôpital [ Upstream commit 4469c0c5b14a0919f5965c7ceac96b523eb57b79 ] The phy_get_internal_delay function could try to access to an empty array in the case that the driver is calling phy_get_internal_delay without defining delay_values and rx-internal-delay-ps or tx-internal-delay-ps is defined to 0 in the device-tree. This will lead to "unable to handle kernel NULL pointer dereference at virtual address 0". To avoid this kernel oops, the test should be delay >= 0. As there is already delay < 0 test just before, the test could only be size == 0. Fixes: 92252eec913b ("net: phy: Add a helper to return the index for of the internal delay") Co-developed-by: Enguerrand de Ribaucourt Signed-off-by: Enguerrand de Ribaucourt Signed-off-by: Kévin L'hôpital Reviewed-by: Russell King (Oracle) Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/phy/phy_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index a42df2c1bd043..bbc459f97b7b0 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2954,7 +2954,7 @@ s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev, if (delay < 0) return delay; - if (delay && size == 0) + if (size == 0) return delay; if (delay < delay_values[0] || delay > delay_values[size - 1]) { -- 2.43.0