From patchwork Thu Aug 24 01:38:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 94273 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1qYzKr-006WKh-G3; Thu, 24 Aug 2023 01:40:33 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239107AbjHXBj6 (ORCPT + 1 other); Wed, 23 Aug 2023 21:39:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239128AbjHXBja (ORCPT ); Wed, 23 Aug 2023 21:39:30 -0400 Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D900610FC for ; Wed, 23 Aug 2023 18:39:11 -0700 (PDT) Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 78638807C4; Thu, 24 Aug 2023 03:39:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1692841149; bh=66jlWYI6u7UpHycVpxDeaFTO7Z2w8Drh+F3eeYqhcqk=; h=From:To:Cc:Subject:Date:From; b=t8/Ey5ppHIIVgGvVVTFGdBlSeXtxzhEjZ6+QvYAzTjE36HCs80yxXcdFrlpd0gTYO 9sa6WCUaIoNsoKjjE/FEK/kk0EJH1SR/qpGd3o9v1lHs0mzf0bxW7E8nJks+zUDsFk 51sklLBAe6pmyetqhJLzj9WwA4p7xC2q5gqnwDXJmtSdN44OmGqNYdHFIEOjFdiYcm 7aS5+m3Wi3gi8ZPoCgC1z8tHC4NNXgPR60xqh2dzoJhmHJ5ppPowwnOIJMxzDKrj7T ZW1Siwb0Os44EOmZswgvoaOqwbxfLP6Yn8XKxicd4ZqReV0C2B822d7cSsK3qDkZLu ogmbky8r3rWjA== From: Marek Vasut To: linux-media@vger.kernel.org Cc: Marek Vasut , Adam Ford , Benjamin Gaignard , Ezequiel Garcia , Mauro Carvalho Chehab , Philipp Zabel , linux-rockchip@lists.infradead.org Subject: [PATCH] media: hantro: Check whether reset op is defined before use Date: Thu, 24 Aug 2023 03:38:58 +0200 Message-Id: <20230824013858.303105-1-marex@denx.de> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -2.5 (--) X-LSpam-Report: No, score=-2.5 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1 autolearn=ham autolearn_force=no The i.MX8MM/N/P does not define the .reset op since reset of the VPU is done by genpd. Check whether the .reset op is defined before calling it to avoid NULL pointer dereference. Note that the Fixes tag is set to the commit which removed the reset op from i.MX8M Hantro G2 implementation, this is because before this commit all the implementations did define the .reset op. Fixes: 6971efb70ac3 ("media: hantro: Allow i.MX8MQ G1 and G2 to run independently") Signed-off-by: Marek Vasut Reviewed-by: Chen-Yu Tsai Tested-by: Chen-Yu Tsai Reviewed-by: Adam Ford --- Cc: Adam Ford Cc: Benjamin Gaignard Cc: Ezequiel Garcia Cc: Mauro Carvalho Chehab Cc: Philipp Zabel Cc: linux-media@vger.kernel.org Cc: linux-rockchip@lists.infradead.org --- drivers/media/platform/verisilicon/hantro_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c index 423fc85d79ee3..50ec24c753e9e 100644 --- a/drivers/media/platform/verisilicon/hantro_drv.c +++ b/drivers/media/platform/verisilicon/hantro_drv.c @@ -125,7 +125,8 @@ void hantro_watchdog(struct work_struct *work) ctx = v4l2_m2m_get_curr_priv(vpu->m2m_dev); if (ctx) { vpu_err("frame processing timed out!\n"); - ctx->codec_ops->reset(ctx); + if (ctx->codec_ops->reset) + ctx->codec_ops->reset(ctx); hantro_job_finish(vpu, ctx, VB2_BUF_STATE_ERROR); } }