From patchwork Thu Apr 13 10:47:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 82913 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp950912vqo; Thu, 13 Apr 2023 04:11:05 -0700 (PDT) X-Google-Smtp-Source: AKy350bXySlm38zPBUVg6ymAlWlIfvA7O5ylGgIG8cLUgeXubuYLv7uuw0wybNB428VAXakNGUt3 X-Received: by 2002:a17:90a:3f81:b0:23f:9d83:ad76 with SMTP id m1-20020a17090a3f8100b0023f9d83ad76mr1425126pjc.23.1681384265098; Thu, 13 Apr 2023 04:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681384265; cv=none; d=google.com; s=arc-20160816; b=iLOl9uPJzmIcuJtuagmymbr2Ixv+fuvqCfhWvK/S49oUKnB3Z9NczkZ0n/1NTy+zuT ksnMxgPFiCFD3N1ytnlt68t/mlYqSZ3XAz/gbidDdm/TFdTJZ2ZMI2OvDIfOBsMSUEcD fW2CMbxtbHVuZoT5yf3/D00GkiuM5RanFC1mKbNqz2uHCckT4Z6fzUOWCxF9UvatdD2P OKYemHTRtCxfnhR7qsaun0nyJnaDok7p3++s+grG9HI/8LJnzPCudKB3MugIrEXfcoAp PAnGSpqMqGuY0wrqK5ou2I41srJMfc/zLmM7+dwQ7/4b53iW4+fJRx/yEKB/j5SPTgMz cZlg== 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=/wldwlIA8bPao513CFYe309j1XgDCHF8G6OMQxDAbe8=; b=kTv9rAi9DzYV7FybYytmXtWXddzmbe6/1Yo5JBSe5XrL/HtZpsVZDn77A3p8O2dF89 TtDELjymnAPPdP3pqPvN7bf5ki+NcF1sX5rm2Hj2uqUJcwFXLt/WBlob4RwkgKqoR76l ActU77GwhlBNh0/nME8+V1+4vdlg3+55p9ofA17libWf76yROhDJJ4oTjW6gcnkJWKLm fHjIl9OWa6rv3SpcuzHzSSeXCPEQBJtzGz3MZdFIJUNedXn38i6EgsXguke9qmioSEF1 NZ2tN2w/yTl3QE3RxVC76EoQxetZsaM5tO4cn5DkcWxVJfWYc1gj9DWhQ1zUxLcvaNoM wkww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=LmV0vxnc; 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 d15-20020a17090ab30f00b0023fc6dc1092si4551736pjr.145.2023.04.13.04.10.53; Thu, 13 Apr 2023 04:11:05 -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=LmV0vxnc; 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 S230370AbjDMKtW (ORCPT + 99 others); Thu, 13 Apr 2023 06:49:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbjDMKtV (ORCPT ); Thu, 13 Apr 2023 06:49:21 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C20D1BC1; Thu, 13 Apr 2023 03:48:45 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7890:9d79:409d:b354]) (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 5A6AC660320E; Thu, 13 Apr 2023 11:48:04 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1681382884; bh=G8T37k5l0CO+3iJ6HX4YP7p8rPxzJMywp+4MNjZsams=; h=From:To:Cc:Subject:Date:From; b=LmV0vxncSegEwhyO8MRwkkNnP8VdC+M1/lR330p6ZAyiVGvaQ5jpI/KUA2CUud4Rs t1NFSc2UySaWM5vs/BiVyYBuZg+NOBJg13HiANdPHxtUVIj55/MSjwRn3NJMjBsqvD RbFJUP1CCV9AxbeypuTvb71elHTG7dbM71dZqeX6mc6JooN60QojrB0xP8RUy9nWuB FxcJZa/vofYh9SmMeEn8+GYXagWdpWXsWG7/Rb8BKb0fSXd9ehOH2BarM/NrrHrNMr eB5GgCwFE2PNsbbRU0kKQ18Pqrz/V6sUIBKxJMy0B5s4ap+eeTIRuWQG1cfGNq5xnu 80hV+fLj/FIHA== From: Benjamin Gaignard To: ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, mchehab@kernel.org, m.szyprowski@samsung.com Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v2] media: verisilicon: Fix crash when probing encoder Date: Thu, 13 Apr 2023 12:47:56 +0200 Message-Id: <20230413104756.356695-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, 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?1763044902572228914?= X-GMAIL-MSGID: =?utf-8?q?1763059187021479667?= ctx->vpu_dst_fmt is no more initialized before calling hantro_try_fmt() so assigne it to vpu_fmt led to crash the kernel. Like for decoder case use 'fmt' as format for encoder and clean up the code. Signed-off-by: Benjamin Gaignard Tested-by: Marek Szyprowski Fixes: db6f68b51e5c ("media: verisilicon: Do not set context src/dst formats in reset functions") Reviewed-by: Nicolas Dufresne Reviewed-by: AngeloGioacchino Del Regno --- version 2: - Remove useless vpu_fmt. drivers/media/platform/verisilicon/hantro_v4l2.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c index 8f1414085f47..d71f79471396 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -275,7 +275,7 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, struct v4l2_pix_format_mplane *pix_mp, enum v4l2_buf_type type) { - const struct hantro_fmt *fmt, *vpu_fmt; + const struct hantro_fmt *fmt; bool capture = V4L2_TYPE_IS_CAPTURE(type); bool coded; @@ -295,11 +295,7 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, if (coded) { pix_mp->num_planes = 1; - vpu_fmt = fmt; - } else if (ctx->is_encoder) { - vpu_fmt = ctx->vpu_dst_fmt; - } else { - vpu_fmt = fmt; + } else if (!ctx->is_encoder) { /* * Width/height on the CAPTURE end of a decoder are ignored and * replaced by the OUTPUT ones. @@ -311,7 +307,7 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, pix_mp->field = V4L2_FIELD_NONE; v4l2_apply_frmsize_constraints(&pix_mp->width, &pix_mp->height, - &vpu_fmt->frmsize); + &fmt->frmsize); if (!coded) { /* Fill remaining fields */