From nobody Sat Nov 30 05:31:03 2024 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB9E522075 for ; Wed, 11 Sep 2024 07:39:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726040362; cv=none; b=QgW/zCBXgQLeqT9VP2pIjNCHPcfXnPGEM7+F+isFWcOdyJQUT/DBFHMl2BvPTWGNJ9+BtlyWrfMqyOyLJjJxHv3rf1zXBxj8oqsjXVHLYtDPbNG6l99VOIRmkCwkeCfz48Mr5dYMkgfO5q82oRJThQtLoLR7ZJNe4TMxk9THTDg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726040362; c=relaxed/simple; bh=HoxR8vfEtIHFIrwB9+FtaybMhmPgqhhqbF2v2L94xzE=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=sN65XE+gm8JukCcOzOa61JkU4QzDUZft4Xbs5xSatvE7W0uH5Sh7SanECW5lWP/6jwF5HnQ5HOSvsLptLNplNNJtrGpSMz22ViSYYSjZeec19PmnKXqwQF0XzZj8kPmChQw5hqQYyy+NhgLmoQOOEVH8khoYeJEKUYeK1XZbmaQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=cDT+bkpY; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cDT+bkpY" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-374d29ad870so3987507f8f.3 for ; Wed, 11 Sep 2024 00:39:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726040359; x=1726645159; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=jMhPnhQLGUUwFA6J63dF4flmVGV7ie7Si62HtCm+ens=; b=cDT+bkpYQyZGhu3P5SC+9wRt3DDUZDG+o0mFvWTTbUaSkPeNFz/0SOtFj3dxIms8jI 88G9BPmqnbCSP9qddzulYeAxdZ239W7TjoWuKTMsYwjE6PqYoRc9MOrC8WcFI+/GuWWQ iZUPADirUTqITvaVUW3gWT1bR0es7jI0NGBHZiKH0A6HMo+lVvG0BZJ4NZSuDREwvg3b p2wTJWtiGdxIJ9ucgntp7yRv9DKIXiQxEuR+fi0VJqSbmBwcs2Oc9EXBn8SVJgrLXHkl aja71qCS5dOQMsRZ6KwAXoEUDzOe7ATFjN/jkT7REtA5NaIdDbMcjJw6QZjW5ME9e/0s tmuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726040359; x=1726645159; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jMhPnhQLGUUwFA6J63dF4flmVGV7ie7Si62HtCm+ens=; b=ww0O3rY86WQDUfDCOh8wWXc9w6nuyrKvxz9uAP4q3dTJXLETbo7PTiP1EXWOl3AZfA Mq/n3pRq+dvnkRGmFzFEnqKobhh89xsGBP0uKXVglicnrxaJH2t6aTGJmV4sC+Ukdj7t 4DRlZVcxc8vhehMF+x8TqNpcGRxhh/sME9KaM1Py+JMZkAlAP+mQ8cT0C87S+zFGQ4Zw 2RJNSVQFXlkIhjDFLwfzuJyDdRd9PypAiQR7L7wQD0W/oUcyyIFcy8KoroFwCkYu24eQ qh8ybzLW9t46v8K11GJOmj3Biau/y2NTRkzmoEP460vITI818NeDq8RGgDXk3T3mdmWx Gkfg== X-Forwarded-Encrypted: i=1; AJvYcCX2+wyodTx8I/VO3LYSJRCLNFy78HpRinqHurrwzzAYSqouSfJaYho5p0fFTFfSOGRdYmiEwXz3nr1auZI=@vger.kernel.org X-Gm-Message-State: AOJu0YwjtKnzS5TyIY+EhzzXmcntVZ0gsCXttOcvWOpaGBpZPVfd2dvo rQOW1yPxDKTwgMtJ2Ghz0BR4b8zwkVEz9nVGB51pn7Y/COsvmA5n1Ev4azSUsOE= X-Google-Smtp-Source: AGHT+IESuS36LExi/2RVMu8sWMe6uqy4QE6i31lVfI6gt/QUy4qRreYxyP5mTDnkIk3YvBnM5tmX7A== X-Received: by 2002:a5d:6945:0:b0:374:b24e:d2bf with SMTP id ffacd0b85a97d-378895d46c9mr11371355f8f.27.1726040359142; Wed, 11 Sep 2024 00:39:19 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42cc01d3d17sm41603025e9.0.2024.09.11.00.39.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 00:39:18 -0700 (PDT) Date: Wed, 11 Sep 2024 10:39:15 +0300 From: Dan Carpenter To: Nikita Shubin Cc: Hartley Sweeten , Alexander Sverdlin , Russell King , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] ep93xx: clock: Fix off by one in ep93xx_div_recalc_rate() Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The psc->div[] array has psc->num_div elements. These values come from when we call clk_hw_register_div(). It's adc_divisors and ARRAY_SIZE(adc_divisors)) and so on. So this condition needs to be >=3D instead of > to prevent an out of bounds read. Fixes: 9645ccc7bd7a ("ep93xx: clock: convert in-place to COMMON_CLK") Signed-off-by: Dan Carpenter Acked-by: Alexander Sverdlin Reviewed-by: Nikita Shubin --- arch/arm/mach-ep93xx/clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c index 85a496ddc619..e9f72a529b50 100644 --- a/arch/arm/mach-ep93xx/clock.c +++ b/arch/arm/mach-ep93xx/clock.c @@ -359,7 +359,7 @@ static unsigned long ep93xx_div_recalc_rate(struct clk_= hw *hw, u32 val =3D __raw_readl(psc->reg); u8 index =3D (val & psc->mask) >> psc->shift; =20 - if (index > psc->num_div) + if (index >=3D psc->num_div) return 0; =20 return DIV_ROUND_UP_ULL(parent_rate, psc->div[index]); --=20 2.45.2