From patchwork Wed Dec 6 16:37:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Flavio Ceolin X-Patchwork-Id: 10096481 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 8EBE960210 for ; Wed, 6 Dec 2017 16:38:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81AF4289AE for ; Wed, 6 Dec 2017 16:38:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76C5C28BD7; Wed, 6 Dec 2017 16:38:17 +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=unavailable 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 38D5C289AE for ; Wed, 6 Dec 2017 16:38:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752145AbdLFQiE (ORCPT ); Wed, 6 Dec 2017 11:38:04 -0500 Received: from mga11.intel.com ([192.55.52.93]:5970 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751208AbdLFQiA (ORCPT ); Wed, 6 Dec 2017 11:38:00 -0500 Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Dec 2017 08:37:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,368,1508828400"; d="scan'208";a="654184" Received: from faceolin-mobl2.amr.corp.intel.com ([10.254.118.233]) by orsmga006.jf.intel.com with ESMTP; 06 Dec 2017 08:37:56 -0800 From: Flavio Ceolin To: linux-kernel@vger.kernel.org Cc: Flavio Ceolin , Andrzej Pietrasiewicz , Jacek Anaszewski , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org (open list:ARM/SAMSUNG S5P SERIES JPEG CODEC SUPPORT), linux-media@vger.kernel.org (open list:ARM/SAMSUNG S5P SERIES JPEG CODEC SUPPORT) Subject: [PATCH] media: s5p-jpeg: Fix off-by-one problem Date: Wed, 6 Dec 2017 08:37:45 -0800 Message-Id: <20171206163746.8456-1-flavio.ceolin@intel.com> X-Mailer: git-send-email 2.9.5 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP s5p_jpeg_runtime_resume() does not call clk_disable_unprepare() for jpeg->clocks[0] when one of the clk_prepare_enable() fails. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Flavio Ceolin Acked-by: Andrzej Pietrasiewicz --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index faac816..79b63da 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -3086,7 +3086,7 @@ static int s5p_jpeg_runtime_resume(struct device *dev) for (i = 0; i < jpeg->variant->num_clocks; i++) { ret = clk_prepare_enable(jpeg->clocks[i]); if (ret) { - while (--i > 0) + while (--i >= 0) clk_disable_unprepare(jpeg->clocks[i]); return ret; }