Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp461470ybl; Tue, 28 Jan 2020 06:20:20 -0800 (PST) X-Google-Smtp-Source: APXvYqwZaFQRppuO72TZ0mcH1Mu1wvMG5tHmBLY+3Is0dnT9hmnuARv82y5SGqtN0d8ahb9ejGgz X-Received: by 2002:aca:1108:: with SMTP id 8mr2975487oir.127.1580221220128; Tue, 28 Jan 2020 06:20:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580221220; cv=none; d=google.com; s=arc-20160816; b=UuK2HeIPqRv3lsu2Rh/crzmVHjMxhCM4w0QtsY921QSrZzzHjUrxxHnE0cSfo71+bW to5WgR5kJALo60ZnM5KjFTTWOS3TTpY2+KH9CuEcFLUMT5GAp2IGyaLRQaTIPGkL+45e THetMxcQzgU9VIuipJg0XVjIK1/QSS3uXFujveod5l6WUdx6MbRuxXNcXvlIRchH5AVZ +tL1nRE2FEpfPtHbPmuPPv/ckDP4rfexHw/2MofGDErPfUi8BJGx2Os05Qk6PsMhxiNM 7y3VTFT56VGoUfVtrES/YVOg+cg/h1xSxRyFqFlxYkYf0gcgtI6SQwltPyXCxk2boVn7 JV/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Le82ZKwRNpGiASS7zMeIhU8xd4hE+G4rB5KFZp8t99o=; b=aZgF1kjlbIxlqGPMnFmOH4xWcitVfGO7lww8gcZcGUogHqn+yT4iUOxaGLGKYSOTdM kfY7JyyMn3+MRAEsVR/Ayxkn42Veq8ipxbzhB9P7u0LWnqxMs4/Bl4DTn0WP4zZ/m59A bIC9gKx+9MKPqtPblzoOG7guQa5o4GSLyI2k9sGTrHVXAJXPkVjHBPa/tcrvbVFHDxKT IUpfu7rq0hFsmjpY6/Ui3mcbOIbGSQOCDbQEivMGjg0KE3D6zddQ05fK6fUMXDXLk/Yd Dwlf7kvkcee39JEUVsdRwHatMAhJWlmnsU7o9w+TgXb4e/8R/m34GlzQohhUvSdrZhBG OhIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sgUkTJvX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r10si3805367otk.83.2020.01.28.06.20.08; Tue, 28 Jan 2020 06:20:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sgUkTJvX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730401AbgA1OSD (ORCPT + 99 others); Tue, 28 Jan 2020 09:18:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:41792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730579AbgA1ORz (ORCPT ); Tue, 28 Jan 2020 09:17:55 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2128321739; Tue, 28 Jan 2020 14:17:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221074; bh=YGvwK8iRc3LVChJ9irN+HSCVeRZqt8+L1CL2oYqkIiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sgUkTJvXFf9q7IQ/IS03s1N24BUqSlAe/nwFsKmXGPvSIIQACbOs/OnxEI7DstghF W2mjEt2mV4PM/piim8cI6la2GC7sJgeCITpjLvv4UG4ZffDoohOUQaZDeDvWBcGmIR EstGYYIYxRAgqYtNL7FTHtr3v+P7y1VUNARMXH2I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Axel Lin , Mark Brown , Sasha Levin Subject: [PATCH 4.9 079/271] regulator: pv88080: Fix array out-of-bounds access Date: Tue, 28 Jan 2020 15:03:48 +0100 Message-Id: <20200128135858.436677287@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Axel Lin [ Upstream commit 3c413f594c4f9df40061445667ca11a12bc8ee34 ] Fix off-by-one while iterating current_limits array. The valid index should be 0 ~ n_current_limits -1. Fixes: 99cf3af5e2d5 ("regulator: pv88080: new regulator driver") Signed-off-by: Axel Lin Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/pv88080-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/pv88080-regulator.c b/drivers/regulator/pv88080-regulator.c index 954a20eeb26f8..a40ecfb772107 100644 --- a/drivers/regulator/pv88080-regulator.c +++ b/drivers/regulator/pv88080-regulator.c @@ -279,7 +279,7 @@ static int pv88080_set_current_limit(struct regulator_dev *rdev, int min, int i; /* search for closest to maximum */ - for (i = info->n_current_limits; i >= 0; i--) { + for (i = info->n_current_limits - 1; i >= 0; i--) { if (min <= info->current_limits[i] && max >= info->current_limits[i]) { return regmap_update_bits(rdev->regmap, -- 2.20.1