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 58EA4C54E90 for ; Thu, 22 May 2025 16:35:29 +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:Message-ID:Date:To:Cc:From: Subject:References:In-Reply-To:Content-Transfer-Encoding:MIME-Version: Content-Type:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3zWf2662MmuwlNPDC7J+4Jz4vKOyVGvHz+5ZrsY6fWs=; b=A706u03g+qjRsw4CoTZD0AFSyA 0x5AviXtWe3gbeGrXN7E2qiP5u5iNfa0dNogy7+SN4MbpTz6kCFA36zICW8snwHvqaCG4Lg3jGBkz il5mXrubE2P5oIIeeuKLebEB02ewRoxbCyeoy8LilhDBEPdBqRkkuNY66VrgjuCaazlZuNZ/uYvqa v/xh30qPSLIroHHA54HfQcICG9sbCg7WsB9uaZAE7OG2aN1WwYX/d+FL3YB4e6jTKKcT4Iia5bLzp tak2lj7Wd6UE55iq2ARhVdvFFKXVJl94yomFK/f6SyognMk12U9srA1zD9M4oWbP3ZinnSOkFaZYC Bg5xaYhg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uI8t7-00000001bOB-1hco; Thu, 22 May 2025 16:35:21 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uI8oP-00000001afG-3G0v; Thu, 22 May 2025 16:30:30 +0000 Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:30c3:8bbb:632f:b0c9]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3A740165B; Thu, 22 May 2025 18:30:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1747931405; bh=9w6AYxG86+ShRJPYPhJz6k6F0yijUzIA6kRpB5v/haw=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=LJoybMKE0uXs+gwjKFQvbLyn6wocyrg3eCl8WJTj/sXmpHKBUm+AM3k9a5zKRFdSS g5piWZPdx2GI3MLodcLSG5eI6ECcYbSPmoYoMlXJwF51Krs6c4Ju7n4+X65mlQ890g 2eaoiPS9Yuhf3RDo+4YYHObk40iw7ZpnAoPXTFJw= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20250522154210.GT12514@pendragon.ideasonboard.com> References: <20250522150944.400046-2-stefan.klug@ideasonboard.com> <20250522150944.400046-3-stefan.klug@ideasonboard.com> <20250522154210.GT12514@pendragon.ideasonboard.com> Subject: Re: [PATCH 1/3] media: rkisp1: Cleanup error handling From: Stefan Klug Cc: linux-media@vger.kernel.org, Dafna Hirschfeld , Mauro Carvalho Chehab , Heiko Stuebner , linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org To: Laurent Pinchart Date: Thu, 22 May 2025 18:30:25 +0200 Message-ID: <174793142530.244022.2578213319638259858@localhost> User-Agent: alot/0.12.dev16+g501a9541e2e6.d20250519 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250522_093029_952149_F2272871 X-CRM114-Status: GOOD ( 19.53 ) 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 Hi Laurent, Thank you for the review. Quoting Laurent Pinchart (2025-05-22 17:42:10) > Hi Stefan, >=20 > Thank you for the patch. >=20 > On Thu, May 22, 2025 at 05:08:38PM +0200, Stefan Klug wrote: > > Do not call media_entity_cleanup() when media_entity_pads_init() fails. >=20 > Why is it an issue ? The media_entity_cleanup() documentation clearly > states >=20 > * Calling media_entity_cleanup() on a media_entity whose memory has been > * zeroed but that has not been initialized with media_entity_pad_init() = is > * valid and is a no-op. >=20 > This is by design to simplify error handling in drivers. Oops. It was simple mechanical thing. I'll remove it in v2. Regrads, Stefan >=20 > > As a drive-by fix handle an (very unlikely) error in > > rkisp1_params_init_vb2_queue(). > >=20 > > Signed-off-by: Stefan Klug > > --- > > .../media/platform/rockchip/rkisp1/rkisp1-params.c | 11 +++++++---- > > 1 file changed, 7 insertions(+), 4 deletions(-) > >=20 > > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c b/d= rivers/media/platform/rockchip/rkisp1/rkisp1-params.c > > index b28f4140c8a3..918eb06c7465 100644 > > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c > > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c > > @@ -2763,7 +2763,9 @@ int rkisp1_params_register(struct rkisp1_device *= rkisp1) > > vdev->queue =3D &node->buf_queue; > > vdev->device_caps =3D V4L2_CAP_STREAMING | V4L2_CAP_META_OUTPUT; > > vdev->vfl_dir =3D VFL_DIR_TX; > > - rkisp1_params_init_vb2_queue(vdev->queue, params); > > + ret =3D rkisp1_params_init_vb2_queue(vdev->queue, params); > > + if (ret) > > + goto err_mutex; > > =20 > > params->metafmt =3D &rkisp1_params_formats[RKISP1_PARAMS_FIXED]; > > =20 > > @@ -2777,19 +2779,20 @@ int rkisp1_params_register(struct rkisp1_device= *rkisp1) > > node->pad.flags =3D MEDIA_PAD_FL_SOURCE; > > ret =3D media_entity_pads_init(&vdev->entity, 1, &node->pad); > > if (ret) > > - goto error; > > + goto err_mutex; > > =20 > > ret =3D video_register_device(vdev, VFL_TYPE_VIDEO, -1); > > if (ret) { > > dev_err(rkisp1->dev, > > "failed to register %s, ret=3D%d\n", vdev->name, = ret); > > - goto error; > > + goto err_media; > > } > > =20 > > return 0; > > =20 > > -error: > > +err_media: > > media_entity_cleanup(&vdev->entity); > > +err_mutex: > > mutex_destroy(&node->vlock); > > return ret; > > } >=20 > --=20 > Regards, >=20 > Laurent Pinchart >