Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2026889rwl; Thu, 13 Apr 2023 00:09:19 -0700 (PDT) X-Google-Smtp-Source: AKy350aOT67sPJ00UkRjCqLrudrngTBJj8bQ2Alp9TgV3xP/oQhOXcLhg2b3uQNJOjNGT+wWi+Lb X-Received: by 2002:a17:903:248:b0:1a1:7da3:ef5b with SMTP id j8-20020a170903024800b001a17da3ef5bmr1117404plh.7.1681369759412; Thu, 13 Apr 2023 00:09:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681369759; cv=none; d=google.com; s=arc-20160816; b=Tix9eUz7jcjjnexC3NbPMjsAF3BpCZ4d4H0c/5lvXjp1UJ2vyWiA5Iccvd114CJO1Y 2OhfPpLIjIhRjcrhPI3D67zgbsaOBLBlvOAkVdVK+gc59cR3ZhaFZMk17QRbcBlKVrlU DLXzHl2BohUWhOWtyD0YnI0D7xAg+pzKHn/uV8cTOeHdlOyUfLDh2tqZkLQ9X7NcgIG+ uePn/u50/HQ3pCzVqiUTWtSrlG6ErdSV7eiDNX0gCoLaPXtnJJrI4oDmD7ADLeoBwTrt dQ0+7MtRuTPaZb2POj8SqrjzNOSrY2zYena/KcQ8RxvFbIUM5MfhFs4dCKLIDITXxJYO xHQA== 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=2CYSDmkDbH42bNL5OGYgCVTs5oiv0UsXqTBbCfPrEwU=; b=GEGIGDxj+ICPgVm8OmJ7sGQ/gjxbo49eB8SHTdmPct0Z+64yf7gJVzoDRYHKZEE9u3 kRPaQ4BcbknzaxxjS4z3hIVLeBNLWyme1vf0FQjz4oBFjoEN8YiznLIXTJfdA2/aI2AI 9UK3IrvLtzPnoC+qKj5mDlAHAZKBY8wyU1hllGonYUW2baySzNGqhhEQK66Q0a39V6Q7 MKayrMTg9szWMSAWXcX1HNcv0chLTmgIITccGTMJgdocE9EA5MCRF1mZ5bF+rYQCbzxd hLyLyXIoHpTy7By58qCI4T8T94P+ydalokl28Ze4EAardzZayi3TjJcg6a0wWDEO7IVM mFdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=mf8TE0H9; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ja3-20020a170902efc300b001a1d6a9c6f1si1317607plb.124.2023.04.13.00.09.08; Thu, 13 Apr 2023 00:09:19 -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=mf8TE0H9; 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 S229689AbjDMHD5 (ORCPT + 99 others); Thu, 13 Apr 2023 03:03:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjDMHD4 (ORCPT ); Thu, 13 Apr 2023 03:03:56 -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 7C4A64C3D; Thu, 13 Apr 2023 00:03:55 -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 5178A6603206; Thu, 13 Apr 2023 08:03:53 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1681369433; bh=gqkR/A4hNaQu1Et9+WleKx6wTMCeG+gaXQPSwT4fAe8=; h=From:To:Cc:Subject:Date:From; b=mf8TE0H9D2km2vIYP0BrRdoMf5E2u9LfwCBagqA5nVm5tXZe92bQ9PzqG8DiN8MZX Ka8dSuzfL9Et3iL3ZZny1ZAOrj4Tn79xM136gEQbZwQVTlpsW+C7D37r7iC5OC6V8b kelvdb0TueF8IQPwTtKwSv7HZITsMS9fbDsoZLfzDm8aCcjfWurvw2znLJLggf1kRL S9jdYkWJq0cwdFmbK+sR1raoboDO5ArMmIxW6Oy8XwKk2haJsc5HRPUsE1D/eHAzPR k4an7DeeqyhewQv7kQWYuAr7SzO4mGDi7+GvRTXM6Nh8eSANyDVDvhGny8g6vQnzKe OLzyOcJLxhgNg== 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] media: verisilicon: Fix crash when probing encoder Date: Thu, 13 Apr 2023 09:03:44 +0200 Message-Id: <20230413070344.34803-1-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 vpu 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") --- drivers/media/platform/verisilicon/hantro_v4l2.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c index 8f1414085f47..51f528f36241 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -293,13 +293,11 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, pix_mp->pixelformat = fmt->fourcc; } + vpu_fmt = fmt; + 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. -- 2.34.1