From patchwork Wed Jul 3 11:59:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13722143 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 74536C2BD09 for ; Wed, 3 Jul 2024 11:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:Subject:From:Cc:To:MIME-Version:Date:Message-ID:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=14wk1xoShqKk4+Tqff3yRaqtSY9EXTNE7lU+OQYmU88=; b=1GB6HTqmzWLlAf7ATspFOIIpLt XppBj07XSjeJj6eP5xcfnKW7mEK2AuHhMQ6d8ZhMqCm+a0uacOwXiDiAZDXQzZ3F1wAetOMk3egb4 oR61R3omj3yoes5N3TU8yOPr68sOn+QU3vli0DVft5uBpC+aKbY0l02nlTQTF8+2SUA6fETbRPGHk 86nhoYjO+uB39AV/+cQBeJ8Sw5Au05KCsKS/+mAVXVchbAmWH6Xa+SQJWgk+5tXmzlxt7cPWHnKIQ hGqAdi9wcF4yarljuxAenFtBgwEJpfZZqRSD9DqDJvVGW4wba0OR1imL9qLuU+9Yh/mS/1v6h4WSs twsKtnuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOye6-0000000A5eF-2kWj; Wed, 03 Jul 2024 11:59:34 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOydu-0000000A5bs-2V46 for linux-arm-kernel@lists.infradead.org; Wed, 03 Jul 2024 11:59:23 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id DDCBBCE0AD5; Wed, 3 Jul 2024 11:59:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33501C2BD10; Wed, 3 Jul 2024 11:59:18 +0000 (UTC) Message-ID: <2dea6faf-53f6-461a-809b-ec572357ad07@xs4all.nl> Date: Wed, 3 Jul 2024 13:59:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US, nl To: Linux Media Mailing List Cc: Maxime Coquelin , Alexandre Torgue , Sakari Ailus , Alain Volmat , Hugues Fruchet , Linux Stable , "linux-stm32@st-md-mailman.stormreply.com" , linux-arm-kernel@lists.infradead.org, Linux Kernel From: Hans Verkuil Subject: [PATCH] media: stm32: dcmipp: correct error handling in, dcmipp_create_subdevs X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240703_045922_850480_7D01532F X-CRM114-Status: GOOD ( 13.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Alain Volmat Correct error handling within the dcmipp_create_subdevs by properly decrementing the i counter when releasing the subdevs. Fixes: 28e0f3772296 ("media: stm32-dcmipp: STM32 DCMIPP camera interface driver") Cc: stable@vger.kernel.org Signed-off-by: Alain Volmat Signed-off-by: Hans Verkuil [hverkuil: correct the indices: it's [i], not [i - 1].] --- The original patch would cause a crash due to the incorrect indices in the statement after the while. Since 'i' can now become 0, so i - 1 would be a negative index access, which was obviously not the intention. I reverted the patch once I noticed this (better to hang in an infinite loop than to crash), but I want to get a proper fix in. Rather than waiting for that, I decided to just take the original patch from Alain, with just the indices fixed. --- drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c index 4acc3b90d03a..7f771ea49b78 100644 --- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c +++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c @@ -202,8 +202,8 @@ static int dcmipp_create_subdevs(struct dcmipp_device *dcmipp) return 0; err_init_entity: - while (i > 0) - dcmipp->pipe_cfg->ents[i - 1].release(dcmipp->entity[i - 1]); + while (i-- > 0) + dcmipp->pipe_cfg->ents[i].release(dcmipp->entity[i]); return ret; }