From patchwork Tue Feb 14 16:31:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frieder Schrempf X-Patchwork-Id: 13140589 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C1FFC61DA4 for ; Tue, 14 Feb 2023 16:45:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbjBNQpr (ORCPT ); Tue, 14 Feb 2023 11:45:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjBNQpq (ORCPT ); Tue, 14 Feb 2023 11:45:46 -0500 X-Greylist: delayed 656 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 14 Feb 2023 08:45:11 PST Received: from mail.fris.de (mail.fris.de [116.203.77.234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 194D6618C; Tue, 14 Feb 2023 08:45:11 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id AA599BFAED; Tue, 14 Feb 2023 17:33:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=dkim; t=1676392435; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding; bh=uXvqQLB2ducDVDKLFpQL7JrjrtTEw9AsgFdryWzrcek=; b=fk5VondZuRrLk6uEQYDteXpBIZRUVf8yg10Bhg5oq/n59tqyhVLNJUjcZqGt72Gtx49m0L KNsJrwQr5G1eufZKq2nXjOI3zyhrSSQwyJi0MvAkaHngHShmrtsyAnwNWoWHcADCBZFue6 whuQGLkBi0rcVp1jymSkQGjQG6/onhtkP+fwiaX3gUdOxkMPk44ItQIbmkhSJeXUxZL32t uFPypeSR3ALdiR1wWM4C42qUnZ3lE7eC4TgOSSfq/UMzs78yQ/qOpvJjAouqo83jUwK+C5 g2EtAlYlkWc586L6f13jDRuE1UaAe0CBK8owFi3hIq67gijs1MqsiJb/UrHA5g== From: Frieder Schrempf To: Laurent Pinchart , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Mauro Carvalho Chehab , Rui Miguel Silva , Sascha Hauer , Shawn Guo Cc: Frieder Schrempf , Fabio Estevam , NXP Linux Team , Paul Elder , Pengutronix Kernel Team Subject: [PATCH] media: imx: imx7-media-csi: Fix error handling in imx7_csi_async_register() Date: Tue, 14 Feb 2023 17:31:56 +0100 Message-Id: <20230214163200.1448837-1-frieder@fris.de> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Frieder Schrempf If fwnode_graph_get_endpoint_by_id() fails and returns NULL, there is no point in going on. Print an error message a abort instead. Also we don't need to check for an existing asd. Any failure of v4l2_async_nf_add_fwnode_remote() should abort the probe. Suggested-by: Laurent Pinchart Signed-off-by: Frieder Schrempf --- drivers/media/platform/nxp/imx7-media-csi.c | 22 +++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index 886374d3a6ff..a7db310624e2 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -2191,18 +2191,20 @@ static int imx7_csi_async_register(struct imx7_csi *csi) ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(csi->dev), 0, 0, FWNODE_GRAPH_ENDPOINT_NEXT); - if (ep) { - asd = v4l2_async_nf_add_fwnode_remote(&csi->notifier, ep, - struct v4l2_async_subdev); + if (!ep) { + dev_err(csi->dev, "Failed to get remote endpoint\n"); + return -ENOTCONN; + } - fwnode_handle_put(ep); + asd = v4l2_async_nf_add_fwnode_remote(&csi->notifier, ep, + struct v4l2_async_subdev); - if (IS_ERR(asd)) { - ret = PTR_ERR(asd); - /* OK if asd already exists */ - if (ret != -EEXIST) - return ret; - } + fwnode_handle_put(ep); + + if (IS_ERR(asd)) { + ret = PTR_ERR(asd); + dev_err(csi->dev, "Failed to add remote subdev to notifier: %d\n", ret); + return ret; } csi->notifier.ops = &imx7_csi_notify_ops;