From patchwork Tue May 23 16:25:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 98087 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2285655vqo; Tue, 23 May 2023 09:58:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ68xn/bADxc1Bz0VImGlTCFqV5ua/1Ee38W5LlzH1++zJgTt/lo1FMXAhaQFg3hHnEoBJ7z X-Received: by 2002:a05:6a21:32a9:b0:ff:b9c4:a0aa with SMTP id yt41-20020a056a2132a900b000ffb9c4a0aamr17433148pzb.48.1684861114763; Tue, 23 May 2023 09:58:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684861114; cv=none; d=google.com; s=arc-20160816; b=Nbf3Daxzer7K644Rawh0XNxf8GPmEjFcfwa7hO1DKmcQPFulsftKoTwBdNLTUpFo3E MSh0HLMP+VW4l/HBS05tgb5yxexDCAW1A4ILBomEYPVIVfaWttQaZ2wt6D1VTFH0aFxc nHKJhYSm68lVxDC0cBJPBoUsDR0dKceU1DNUiuLsknZpG7cQF6va9kLFeTxMogiVPNLa 5mco2WcO30rrXW4ArxI+RyDeTaNwaLKERot5BlfOLHvLEU74rAToBLRQfS2kgOSOF0Xq Ki9Nw6soIMpIHHuu336hieYS02BgyMmy6/W4F6IDIvcrH53h96QNwqjrEJL5vYQqqn0W o+mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=HMqoOc11QEtjv9Gy9VLpe+tUPN0zZYtQVE/8ub4WEZg=; b=RMWWCnyM13IOAYIwgRzshwjLayAdo9ZYMogibaEm0RjcjHu24s9DXBfpRL7lovIY8T vDN570B1/ldI9UZ/tfqEzggGyBeH12ZIih4uHVsL8nkvdfqb/MO5gbeLPYsPyoSC8m2D spkxlVDm8SRXEZKv0CzOYC8Xj2tdpdKnh4vN/p9cEFv+qcxEsHfTlKaRHvjMKKo5Jl0d fuyfqOO34NFxIf6YSrjd3dtxK1n6YBtOfFgMY4VbIAi0Jd4y/8+J75u52NfNeneseKHf z4qHb7Li6ZHaCIsUMAFNYwdSPaKQJTFb4kdPj+pECCVkBfJDPaXDkZdR8p8pfjAG3rnm m3hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Sjc4Xq4A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m13-20020a63710d000000b0053ef547263csi974761pgc.398.2023.05.23.09.58.20; Tue, 23 May 2023 09:58:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Sjc4Xq4A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237017AbjEWQZb (ORCPT + 99 others); Tue, 23 May 2023 12:25:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233067AbjEWQZ3 (ORCPT ); Tue, 23 May 2023 12:25:29 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE373C2; Tue, 23 May 2023 09:25:24 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:1ba:3e91:de16:9b34]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id CFFC56605961; Tue, 23 May 2023 17:25:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1684859123; bh=m0wdRLijBXDpapk6u3bXRwyWKtwK52v854JhKYzO1nY=; h=From:To:Cc:Subject:Date:From; b=Sjc4Xq4ABljQOpIT49MZaaPtLrwgnBcr6oDj8CHt+k7Lhj2kdV3uHLCPoNtziCzTu rec4ISSSxD8WNs2hJMFigTXAt2D2M2iH+E1jgxTDFAPBrMKDheBGgAMDDUXmt8TxUP yAIxDPZBwgGkZQrmfM1TELJkhvnSNDohXPmre6mGbBouxQBh17/992/yzaFiB1GoRw 9H+avykPJeQS5hgDoZyBOX+0+apYSA+oHFdB/qHBDgBiNu11BPAzNmN7Ws1ICJ5fSg GTQMk6hYEvAeXUklumgZCWnQGRBlXHttBYy7dbR7iMVT6uWol39BG2crC0codYNsIZ HK4Kti7Ps9sUg== From: Benjamin Gaignard To: ezequiel@vanguardiasur.com.ar, nicolas.dufresne@collabora.com, p.zabel@pengutronix.de, mchehab@kernel.org, m.szyprowski@samsung.com, m.tretter@pengutronix.de, didi.debian@cknow.org Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com, hverkuil-cisco@xs4all.nl, kernel@pengutronix.de, regressions@lists.linux.dev, Benjamin Gaignard Subject: [PATCH] media: verisilicon: Additional fix for the crash when opening the driver Date: Tue, 23 May 2023 18:25:15 +0200 Message-Id: <20230523162515.993862-1-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766703401495339576?= X-GMAIL-MSGID: =?utf-8?q?1766704928130476295?= This fixes the following issue observed on Odroid-M1 board: Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 Mem abort info: ... Modules linked in: crct10dif_ce hantro_vpu snd_soc_simple_card snd_soc_simple_card_utils v4l2_vp9 v4l2_h264 rockchip_saradc v4l2_mem2mem videobuf2_dma_contig videobuf2_memops rtc_rk808 videobuf2_v4l2 industrialio_triggered_buffer rockchip_thermal dwmac_rk stmmac_platform stmmac videodev kfifo_buf display_connector videobuf2_common pcs_xpcs mc rockchipdrm analogix_dp dw_mipi_dsi dw_hdmi drm_display_helper panfrost drm_shmem_helper gpu_sched ip_tables x_tables ipv6 CPU: 3 PID: 176 Comm: v4l_id Not tainted 6.3.0-rc7-next-20230420 #13481 Hardware name: Hardkernel ODROID-M1 (DT) pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : hantro_try_fmt+0xa0/0x278 [hantro_vpu] lr : hantro_try_fmt+0x94/0x278 [hantro_vpu] ... Call trace: hantro_try_fmt+0xa0/0x278 [hantro_vpu] hantro_set_fmt_out+0x3c/0x298 [hantro_vpu] hantro_reset_raw_fmt+0x98/0x128 [hantro_vpu] hantro_set_fmt_cap+0x240/0x254 [hantro_vpu] hantro_reset_encoded_fmt+0x94/0xcc [hantro_vpu] hantro_reset_fmts+0x18/0x38 [hantro_vpu] hantro_open+0xd4/0x20c [hantro_vpu] v4l2_open+0x80/0x120 [videodev] chrdev_open+0xc0/0x22c do_dentry_open+0x13c/0x48c vfs_open+0x2c/0x38 path_openat+0x550/0x934 do_filp_open+0x80/0x12c do_sys_openat2+0xb4/0x168 __arm64_sys_openat+0x64/0xac invoke_syscall+0x48/0x114 el0_svc_common+0x100/0x120 do_el0_svc+0x3c/0xa8 el0_svc+0x40/0xa8 el0t_64_sync_handler+0xb8/0xbc el0t_64_sync+0x190/0x194 Code: 97fc8a7f f940aa80 52864a61 72a686c1 (b9400800) ---[ end trace 0000000000000000 ]--- Fixes: db6f68b51e5c ("media: verisilicon: Do not set context src/dst formats in reset functions") Signed-off-by: Benjamin Gaignard Tested-by: Michael Tretter Tested-by: Diederik de Haas Tested-by: Marek Szyprowski --- drivers/media/platform/verisilicon/hantro_v4l2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c index 835518534e3b..61cfaaf4e927 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -397,10 +397,12 @@ hantro_reset_raw_fmt(struct hantro_ctx *ctx, int bit_depth) if (!raw_vpu_fmt) return -EINVAL; - if (ctx->is_encoder) + if (ctx->is_encoder) { encoded_fmt = &ctx->dst_fmt; - else + ctx->vpu_src_fmt = raw_vpu_fmt; + } else { encoded_fmt = &ctx->src_fmt; + } hantro_reset_fmt(&raw_fmt, raw_vpu_fmt); raw_fmt.width = encoded_fmt->width;