Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2506839lqp; Mon, 25 Mar 2024 00:12:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU1I5rZWfYJG9uto9YWxBFqmi/oqs9BSds/nZIaNfScc6XMRGoBWKgqJ02wqvucoMk2JUOsY81LemtqjAUDix0tE+m9GtHmNARtFnpjvA== X-Google-Smtp-Source: AGHT+IHx7o/operKDb/sQn5iCx8ofb9PQ6MIy7HhunjgRbZOpxbTvNRwrp6dApozFURK6oL00tKH X-Received: by 2002:a25:2d23:0:b0:dcf:b5b7:c72 with SMTP id t35-20020a252d23000000b00dcfb5b70c72mr3758822ybt.0.1711350770633; Mon, 25 Mar 2024 00:12:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711350770; cv=pass; d=google.com; s=arc-20160816; b=eVFQN/pFAxKBjnmArEwRXSmoW4LoEcAJGeHJdXzQRVe+mIOjYtxYry45SN+Vjwy61b WYLyqe9x03x9oiWaUVmTgBY14EinAUI52Jvtmw9LgTXe29b5lLTPd6YZYAfTznn2IFn1 IyZud850QjW8Te7g1Xcp4ssmBJ1gt+IQBLyyXKPwBul7LEVdJVPm6lsJe+/f+rEiEFYL fFGLrwV4lLJ3OOq4nbHxgHZ7cE4tZQzj50RmVs795fSOYnsby/lja09fa2ouYm5WzlT0 CafT7/mB8X0DDJ5Es4OSvyrDresXkGI0ulk6ON85dz8LqqP+hXEQltWUatKarffC8kMA 9PMA== 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=Ff7gFBjgK2bdwj3izmVb3F/3vH3gGd24Q5xwjcNapw0=; fh=akhehA9bjmhcj8OY9/y0FWK2AA+CgDdDtqKmH+H03AQ=; b=ZNkYcg+cSOA+kVadhgxEnmCDZ42Rzx4pQjCjV/sMy/qEBPlutpFLoHXIquWJaKud3a 7LS5pi5crTNJqaTgdrMXWRAoedhaqht15F4b/d98Ajot6CiOjt4r5rATOt6BleuhbXEo cim5ByQCaAg9TPATzY+whCSp001K7XlJqiv/MM3iVYd1TTnE2JeWlELidNI4SMKH95HR ziW2exMAYmVeJv1YP0KFmm4Xsie9aNe+m5uc6jrINHyfswuVAv/QwigVB0np21bp1hF2 br5SkQNn745e7jSUpe5/3pkh9xlv53RMK+C97R6Dv/NZ0kCqKcz1j1e2XCMZ6DEXKQQQ tSYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B1v4P2Xq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114984-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114984-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id cm11-20020a05622a250b00b004313c93978dsi4973229qtb.797.2024.03.25.00.12.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 00:12:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-114984-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B1v4P2Xq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114984-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114984-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5CB501C2D2FB for ; Mon, 25 Mar 2024 07:12:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 89EB52E2D27; Mon, 25 Mar 2024 00:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B1v4P2Xq" 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 7335317B505; Sun, 24 Mar 2024 23:42:02 +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=1711323723; cv=none; b=pUm3HZhqS9Qg6eTijNO+iwonR3Yb7iaR2+g9Pd8G7qriRBRRMDnUiYNDqsBUR+0XWyhkCH5Xr/63avK1cM6SasIEnXSieXDzRazPO6Da/+cn03QkNZZHwUSwgukvHPmol0zuwvKFkorYnhMx0a1HVub3s+jIoWcEIyP5TPfijKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323723; c=relaxed/simple; bh=XFtq3XqnESWaeOMaHoGj/4dYIEwo6DIjVgRSahMky7w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S49W6Qo9Zt2VGfJOvbqBRky3kvypdFRjzqscoPKJ6JioCyIlyHz003483Gq04lL0ztk6tocgCqbBP3hDcIAioPiZiwAPRj1Ha/GQov17vQQHMshElkAmuZpyS5DqvA3GTnQj1RhAfQtA27fYoWBkd4/pPrABGqAWyKrnj9sCbZU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B1v4P2Xq; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AA2FC43390; Sun, 24 Mar 2024 23:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323722; bh=XFtq3XqnESWaeOMaHoGj/4dYIEwo6DIjVgRSahMky7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B1v4P2XqngBT8/2ITTy4obx5kDrzopTk/y4ud3ZO+nwin0EenbqRrQ1UkMYV5jpcH 0yPG6EJUwEJQ8HoiAZKinzj7XaoMMQ5o2RQjHSyLNAaJUEKQfyK2tmcVzxLuTk59tr 29JMQDVeJyuTOcQyJAxknxnuq79/scBke3F7UqoVaaA9cZEnvX+2+AjqR+u6S3S0j+ ciHV+HDJSA0wCEpJEQaB5YzyK7ey+AqM/teowObCKT8Bc1sTop85RlOnH0wRX2DgHY bAiAtgCWT3B+AQ5VaGEzwOeRfLO/TYKwjnE3x4fAk9aJuu+izYalVTSTWjDohg3I01 y/CRPaKY4AMZA== 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 5.10 095/238] net: phy: fix phy_get_internal_delay accessing an empty array Date: Sun, 24 Mar 2024 19:38:03 -0400 Message-ID: <20240324234027.1354210-96-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-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 095d16ceafcf8..8654e05ddc415 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2769,7 +2769,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