Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp680485pxb; Tue, 5 Apr 2022 18:30:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWx64Gv2R6pPNhaG14rQSxN8NNr3hKQ/o03C2pCKtTQGHq1qu7oM+wwLh6z6KrwteoRyMd X-Received: by 2002:a17:907:1b15:b0:6d7:13bd:dd62 with SMTP id mp21-20020a1709071b1500b006d713bddd62mr5880534ejc.673.1649208659075; Tue, 05 Apr 2022 18:30:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649208659; cv=none; d=google.com; s=arc-20160816; b=LEogpkD5rfSEZjSsxnbmQdc+a0Qui4yz++3WluUP6Z/1l1xT2OD6pYB3LDBiyov7XF EfII8ZYuPrVxk8VKffnOCOkneok09MnbkAm4rtJScHr6GH2oCqsevo23Q/59itAaxRY5 X36LeY+TYJA9FU0r4bka5osld5PZ3gfjI+pDzzfTjIEi6F2OYz3128Xw3kZAV8ayTt5Y enWCPrBEUeDChWHZbcVmehXQqa2UgkApRywN59sw4OdFrgIWU97UdnLlthc2EqueC3Jy LzKAShrNN+XNwU8HDxS0bHmtufRgvV43LGgNln1rQ8eXbxuJXyoa6L8nfiqKF28uN2a0 cgcg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HorXMGomBqWQaw4vkFKD5HGCDwnXOaZWPfVzErLmErg=; b=usNaPBlvwJh0O68rRw6R8yhbW8RjzfGtu/4CvNMZHoSczWyEmpku4/icxLPql1fJjZ V5GNs5RqHOi+1X25V7ULFReeL9k+wrYb/vSguAgFxXfaNm6rUe6G1ovGvWvYx3YE5Mmq LrG9KwCVQELHH702yfI1b/Po+EwYiGaXWClFjGBQm9NmeO7yG2mnZb3Jb5Isqo5uBfjt WTxtm4phpL6iLVZLi1jf7JTvSGNuSFyWmdgja/wsqN4vWYKx3NWUmyZOTugMoj35F97x m6Q2gBRbdTIY/6Gjo5VtC4DjRzoKLKYf/ScFCKt8exoIYxApfMQRzzdbu1nFbe8xmS9u xecg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="jX/tHwZ+"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kk23-20020a170907767700b006e8007de332si4629685ejc.224.2022.04.05.18.30.26; Tue, 05 Apr 2022 18:30:59 -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=@linuxfoundation.org header.s=korg header.b="jX/tHwZ+"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351038AbiDEKAz (ORCPT + 99 others); Tue, 5 Apr 2022 06:00:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234304AbiDEIYn (ORCPT ); Tue, 5 Apr 2022 04:24:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C282B65C6; Tue, 5 Apr 2022 01:20:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1EE2F60FFB; Tue, 5 Apr 2022 08:20:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3437CC385A0; Tue, 5 Apr 2022 08:20:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649146811; bh=ADEi5SU0fkm1OasEUzfXS5XLxdWFJrLpnS+LEgj9ZRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jX/tHwZ+plIHXqp5I964WB3W3tu+0jITkfMVhxXTcVjmVCvWiB8xRQJTZUT5jWT0D OAx8KwQLOTV2foqocsPxxgfJ8adEYZVvTdTuSaj2Bw1TQc7BxSc1edl+Wio8YZditv FHoDZ7xEnO71+henpLjeNIqJenokQqTbzFwFSCbY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mirela Rabulea , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.17 0897/1126] media: imx-jpeg: Prevent decoding NV12M jpegs into single-planar buffers Date: Tue, 5 Apr 2022 09:27:24 +0200 Message-Id: <20220405070433.852792904@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Mirela Rabulea [ Upstream commit 417591a766b3c040c346044541ff949c0b2bb7b2 ] If the application queues an NV12M jpeg as output buffer, but then queues a single planar capture buffer, the kernel will crash with "Unable to handle kernel NULL pointer dereference" in mxc_jpeg_addrs, prevent this by finishing the job with error. Signed-off-by: Mirela Rabulea Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/imx-jpeg/mxc-jpeg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/media/platform/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/imx-jpeg/mxc-jpeg.c index 4ca96cf9def7..b249c1bbfac8 100644 --- a/drivers/media/platform/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/imx-jpeg/mxc-jpeg.c @@ -947,6 +947,12 @@ static void mxc_jpeg_device_run(void *priv) v4l2_m2m_buf_copy_metadata(src_buf, dst_buf, true); jpeg_src_buf = vb2_to_mxc_buf(&src_buf->vb2_buf); + if (q_data_cap->fmt->colplanes != dst_buf->vb2_buf.num_planes) { + dev_err(dev, "Capture format %s has %d planes, but capture buffer has %d planes\n", + q_data_cap->fmt->name, q_data_cap->fmt->colplanes, + dst_buf->vb2_buf.num_planes); + jpeg_src_buf->jpeg_parse_error = true; + } if (jpeg_src_buf->jpeg_parse_error) { jpeg->slot_data[ctx->slot].used = false; v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); -- 2.34.1