From mboxrd@z Thu Jan 1 00:00:00 1970 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 CC8BBC30653 for ; Thu, 27 Jun 2024 11:19:22 +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:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=I2Ue1DBjGMm7SEfTizzTtEOvykNne46Gvh3acYU0sLA=; b=y20Ni06yXi5QSO3y0nZfQ64qAl GSF6Oq/V+XwV2VxYogEKGm93wgheVMz9RE6ocHyYLsrbHYof73d1tzFd66KfvkhPIcurMH3+fAGZd 0ECGhYqxTm5QLmIop36brua1Hhc11K/yGfe2Hxpv/P7fiKGDfON21mquHitMudLYqEfpcy+Gx3Tuc tOuZaqenimsCU6mqYv5weSoMrTVM4LoAKDOy4mrn41UM3rAEHz0P6073dLe7y2A27fR66AbQhRreK OQ/JCjdRxSk7QpC8Ee6Dt7NkGuOb/9nqUpG7cUSy99hlQybNkOztAcL0Kh4nGDSTn/aV+HptT55IA 3cmyhFcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMn9P-0000000A89k-0p49; Thu, 27 Jun 2024 11:18:51 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMn8b-0000000A7uq-2usW for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 11:18:04 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4921361E1C; Thu, 27 Jun 2024 11:17:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D731CC32786; Thu, 27 Jun 2024 11:17:56 +0000 (UTC) Message-ID: <8587b6cd-2d04-4a2e-b298-e57c792332f1@xs4all.nl> Date: Thu, 27 Jun 2024 13:17:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] media: stm32: dcmipp: correct error handling in dcmipp_create_subdevs To: Alain Volmat , Hugues Fruchet , Mauro Carvalho Chehab , Maxime Coquelin , Alexandre Torgue , Sakari Ailus Cc: stable@vger.kernel.org, linux-media@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20240624084123.3009122-1-alain.volmat@foss.st.com> Content-Language: en-US, nl From: Hans Verkuil In-Reply-To: <20240624084123.3009122-1-alain.volmat@foss.st.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_041802_131360_931C5426 X-CRM114-Status: GOOD ( 16.85 ) 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 On 24/06/2024 10:41, Alain Volmat wrote: > Correct error handling within the dcmipp_create_subdevs by properly > decrementing the i counter when releasing the subdeves. > > Fixes: 28e0f3772296 ("media: stm32-dcmipp: STM32 DCMIPP camera interface driver") > Cc: stable@vger.kernel.org > Signed-off-by: Alain Volmat > --- > drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > 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..4924ee36cfda 100644 > --- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c > +++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c > @@ -202,7 +202,7 @@ static int dcmipp_create_subdevs(struct dcmipp_device *dcmipp) > return 0; > > err_init_entity: > - while (i > 0) > + while (i-- > 0) > dcmipp->pipe_cfg->ents[i - 1].release(dcmipp->entity[i - 1]); > return ret; > } I accidentally merged this one, but this patch isn't right. After this change the [i - 1] indices should be changed to [i]. If i == 1, then the while condition is true, but now i == 0 in the actual statement, so you access out-of-bounds values. I decided to revert it, since it is better to just get stuck in the while loop, then to crash. But a new patch is needed for this. Regards, Hans