Message ID | 20230413070344.34803-1-benjamin.gaignard@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp847004vqo; Thu, 13 Apr 2023 00:24:02 -0700 (PDT) X-Google-Smtp-Source: AKy350ZKqoCIouAQ4sa/bsR0N42Hlq6T2os9W98rS4YPbtLe8wZaY2otUdnatorAzaPu0/SZ7D2s X-Received: by 2002:a17:906:a841:b0:94a:4499:ec30 with SMTP id dx1-20020a170906a84100b0094a4499ec30mr1585835ejb.15.1681370642012; Thu, 13 Apr 2023 00:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681370641; cv=none; d=google.com; s=arc-20160816; b=VJCOIq63FHsSFmEfC6qR0sMPriKUGJbXzxaftoLLGhMrJ1h2WBO5cHgcuZygKxmD5Z X2Z/Z4QFn7+XJysB7aHvxq0pa8hJCZtKvhY1lGVeLvb/PLsHvaBii1jBynswEjnTzqXn Yo6Ib2QJVNf/xXIX7a4rlZYpp1jhGDQ8s8XTDZLpn4vv4ADvDby0vDS3YKNL5GUOgYyN 1va/eKKfh2sNy+qM95mgP0FGYDNWJrBKMZdBhPcicYgHSRewBviqlHKHhBFw8vNsEla8 EhAhUd8rMoxt11mE0VvKQWHNqy71oeISjJTKq6/vpMQ/1SpD7oTmqfDq0pe9CHm89LLx +cZA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o11-20020a1709062e8b00b0094e89de648asi1065150eji.778.2023.04.13.00.23.38; Thu, 13 Apr 2023 00:24:01 -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 S229699AbjDMHD5 (ORCPT <rfc822;peter110.wang@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <benjamin.gaignard@collabora.com> 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 <benjamin.gaignard@collabora.com> 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: <linux-kernel.vger.kernel.org> 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?1763044902572228914?= |
Series |
media: verisilicon: Fix crash when probing encoder
|
|
Commit Message
Benjamin Gaignard
April 13, 2023, 7:03 a.m. UTC
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 <benjamin.gaignard@collabora.com> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> 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(-)
Comments
Le jeudi 13 avril 2023 à 09:03 +0200, Benjamin Gaignard a écrit : > 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 <benjamin.gaignard@collabora.com> > Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> > Fixes: db6f68b51e5c ("media: verisilicon: Do not set context src/dst formats in reset functions") Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> > --- > 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 > >
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.