From patchwork Mon Feb 20 18:57:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 9583491 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9CADE6047C for ; Mon, 20 Feb 2017 18:58:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D52C28680 for ; Mon, 20 Feb 2017 18:58:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F047287EE; Mon, 20 Feb 2017 18:58:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E38AA28680 for ; Mon, 20 Feb 2017 18:58:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750935AbdBTS6f (ORCPT ); Mon, 20 Feb 2017 13:58:35 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:34547 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750868AbdBTS6e (ORCPT ); Mon, 20 Feb 2017 13:58:34 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OLO007KQSPD6R10@mailout2.w1.samsung.com>; Mon, 20 Feb 2017 18:58:25 +0000 (GMT) Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170220185825eucas1p267f2beb1065ad72d6fa12b062a3970a4~lE_AWQ0k70874208742eucas1p2p; Mon, 20 Feb 2017 18:58:25 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3.samsung.com (EUCPMTA) with SMTP id 43.4D.09557.05C3BA85; Mon, 20 Feb 2017 18:58:24 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170220185824eucas1p227fb1d8679f66825702296113c776095~lE9-omN0d0873408734eucas1p2p; Mon, 20 Feb 2017 18:58:24 +0000 (GMT) X-AuditID: cbfec7f2-f790f6d000002555-62-58ab3c50917a Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 6E.87.06687.4AC3BA85; Mon, 20 Feb 2017 18:59:48 +0000 (GMT) Received: from AMDC2768.DIGITAL.local ([106.120.43.17]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OLO00HP0SPB8L20@eusync3.samsung.com>; Mon, 20 Feb 2017 18:58:24 +0000 (GMT) From: Andrzej Hajda To: Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski Subject: [PATCH] PM / OPP: fix off-by-one bug in dev_pm_opp_get_max_volt_latency loop Date: Mon, 20 Feb 2017 19:57:57 +0100 Message-id: <1487617077-21865-1-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNIsWRmVeSWpSXmKPExsWy7djP87oBNqsjDA5dNLK4te4cq8XGGetZ LS7vmsNm8bn3CKPF2iN32S3e/DjLZHHm9CVWix9nulksNj84x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CNewVzcu3sTUw/mLtYuTkkBAwkWhdvZQN whaTuHBvPZDNxSEksIRRYvKEQ1BOI5PEp29bWECq2AQ0Jf5uvgmWEBE4zSixadI6ZhCHWaCP UaLx7yqgDAeHsEC4xNZX9iANLAKqEg/mPmMEsXkFnCU2H4FZJydx81wn8wRG7gWMDKsYRVJL i3PTc4sN9YoTc4tL89L1kvNzNzECg3fbsZ+bdzBe2hh8iFGAg1GJh3fHj1URQqyJZcWVuYcY JTiYlUR4E+RWRwjxpiRWVqUW5ccXleakFh9iNAVaPpFZSjQ5HxhZeSXxhiaG5paGRsYWFuZG RkrivCUfroQLCaQnlqRmp6YWpBbB9DFxcEo1MCbcDvrpvuOPrVRm7x7OgjcTGsXXBR+ZfEy8 Zp/nToftOnM2WD7PaL68N2iRyCoPtQvno0zFXvdqL7th2GpzP9BL4ASH5lmPOF2hT5k2y0Pa g21P3ptfx3hm+v2205mVXyV0jQ5/y2CSbVv9rbji5nEJtbIjPBxqhv6uyzkt8h9eXaT66eVt ayWW4oxEQy3mouJEAFUbYgN0AgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170220185824eucas1p227fb1d8679f66825702296113c776095 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?QW5kcnplaiBIYWpkYRtTUlBPTC1LZXJuZWwgKFRQKRvsgrw=?= =?UTF-8?B?7ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?QW5kcnplaiBIYWpkYRtTUlBPTC1LZXJuZWwgKFRQKRtTYW1z?= =?UTF-8?B?dW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170220185824eucas1p227fb1d8679f66825702296113c776095 X-RootMTR: 20170220185824eucas1p227fb1d8679f66825702296113c776095 References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Reading array at given index before checking if index is valid results in illegal memory access. The bug was detected using KASAN framework. Signed-off-by: Andrzej Hajda Acked-by: Viresh Kumar --- drivers/base/power/opp/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 91ec323..dae6172 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -231,7 +231,8 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev) * The caller needs to ensure that opp_table (and hence the regulator) * isn't freed, while we are executing this routine. */ - for (i = 0; reg = regulators[i], i < count; i++) { + for (i = 0; i < count; i++) { + reg = regulators[i]; ret = regulator_set_voltage_time(reg, uV[i].min, uV[i].max); if (ret > 0) latency_ns += ret * 1000;