Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2523317pxj; Mon, 10 May 2021 05:09:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcSc4mzgG0N+VUPr+XhylvE+TLhEZPIJvfDwoc4FWdnz8xC6d0qKnb0oyPZipajjXcRCuq X-Received: by 2002:aa7:c98b:: with SMTP id c11mr29176121edt.50.1620648545962; Mon, 10 May 2021 05:09:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620648545; cv=none; d=google.com; s=arc-20160816; b=YcJZM6pASOLh8h148nCzkV8AY59gTI3jhO6Uzl4pWdI0/+pU8HpTYUYofZ6L+w+IGg yGHxNxZMsr+Il7X/itBjR2xg/tdNTjQm2rX4UikrqQGTN+seXCOKgwyG7oGb8E0cOo/O aq+nZfs+0S1DPAkICVI4+w0jud9aklAjAt8G5sWE5a4wmmP6tJihcHbLZuhaZPZfPYyJ LnKwt16Q2117IC5ouNN+jOmFGom+k78A27pq57E+vnHjPyCsGruZmb3Qdsuow2ReJNf5 DSkiFWUlkn83iIGBL80yiCRCdpUzBnFBjvDQ00aT8Kd268muQeRyv/GwXBtmBJbM3HAL 1XTg== 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=ZwxJdUIMZMM8HhpON9POjSAUC3zZF1ailRbz0j5b2hU=; b=ChXIZyR7/et9g/oQvN+54aCrZ81BPowkiNUWp8wtwD3UCQGrJGNknPyq4Xj6/IV4am nv0cYbZ6+98QF4GrB+u97Vzt6EAydHJP3CQu5s+mOY7+l2/Av0/Jz+wtvfThlgG7CTL0 ZOf+ESO1BnCbOv3sWp6AT1EGEVbwmXQsvlTG/fhRZ/H75F6wAlUlaBiRFzmSfnCJ3saq CGDo57fAMx5HC0+XNR9d0w6t3IUS6Zvb2ng+MSpzDWYv0596+2wEI/7z209a8UffoPQh y3HWLE318WWTg51wKv7GY/eWzI/0Z4Gfwb6SrOWrQgB2/CLaes9lkISL38ljMRr9iJG/ nfNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qjU137j+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pg9si12593297ejb.22.2021.05.10.05.08.39; Mon, 10 May 2021 05:09:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qjU137j+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S243913AbhEJL5o (ORCPT + 99 others); Mon, 10 May 2021 07:57:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:36600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235776AbhEJLGG (ORCPT ); Mon, 10 May 2021 07:06:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6354861430; Mon, 10 May 2021 10:56:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620644176; bh=LuLsmtNBOVUVcPlscaaqrxu62cTFLbKV2lTknh3M/k8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qjU137j+ynMntDWx82qppfiG83HkqXnH79VzZMWIxtAJMWQefOPv8j0tjuvolWqe2 ohQGl2kBRFuColhLNqAub4Un6tCzvZB0Wa+rid6hFUJjq/otsaU/R/X0VPIX6nU9o8 AhomgiKN3kVXF2bGNeYP92yzfpwEa6Uzh7QoCO84= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Subject: [PATCH 5.11 317/342] media: staging/intel-ipu3: Fix set_fmt error handling Date: Mon, 10 May 2021 12:21:47 +0200 Message-Id: <20210510102020.594975271@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102010.096403571@linuxfoundation.org> References: <20210510102010.096403571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ricardo Ribalda commit ad91849996f9dd79741a961fd03585a683b08356 upstream. If there in an error during a set_fmt, do not overwrite the previous sizes with the invalid config. Without this patch, v4l2-compliance ends up allocating 4GiB of RAM and causing the following OOPs [ 38.662975] ipu3-imgu 0000:00:05.0: swiotlb buffer is full (sz: 4096 bytes) [ 38.662980] DMA: Out of SW-IOMMU space for 4096 bytes at device 0000:00:05.0 [ 38.663010] general protection fault: 0000 [#1] PREEMPT SMP Cc: stable@vger.kernel.org Fixes: 6d5f26f2e045 ("media: staging/intel-ipu3-v4l: reduce kernel stack usage") Signed-off-by: Ricardo Ribalda Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/ipu3/ipu3-v4l2.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/staging/media/ipu3/ipu3-v4l2.c +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c @@ -669,6 +669,7 @@ static int imgu_fmt(struct imgu_device * struct imgu_css_pipe *css_pipe = &imgu->css.pipes[pipe]; struct imgu_media_pipe *imgu_pipe = &imgu->imgu_pipe[pipe]; struct imgu_v4l2_subdev *imgu_sd = &imgu_pipe->imgu_sd; + struct v4l2_pix_format_mplane fmt_backup; dev_dbg(dev, "set fmt node [%u][%u](try = %u)", pipe, node, try); @@ -737,6 +738,7 @@ static int imgu_fmt(struct imgu_device * ret = -EINVAL; goto out; } + fmt_backup = *fmts[css_q]; *fmts[css_q] = f->fmt.pix_mp; if (try) @@ -744,6 +746,9 @@ static int imgu_fmt(struct imgu_device * else ret = imgu_css_fmt_set(&imgu->css, fmts, rects, pipe); + if (try || ret < 0) + *fmts[css_q] = fmt_backup; + /* ret is the binary number in the firmware blob */ if (ret < 0) goto out;