Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2748156pxj; Mon, 10 May 2021 09:51:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9O59MiA6WmC8xIUEDC10eeC3v56jUFyMi79FbJmXX03mpjk7peEpyubqtYcV2tFHzkzLK X-Received: by 2002:a05:6638:1928:: with SMTP id p40mr23084418jal.22.1620665461638; Mon, 10 May 2021 09:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620665461; cv=none; d=google.com; s=arc-20160816; b=NhdzUpjFmOcO7rhsZc+zKud9GfIW1BRK8OpH6OGCvco8LGJcE9G8NpPlFqBSoCjACP pfVclSBhepm6DX5SauyyKHWEfF6+rP5yj8G8g3L2M8C3KaPgluJG8jD/Q3MLkBoepkfd rlT9Uv6ydbmJI1nbap355QtUproBXIWV8w4UBp6JCcDx9Wzm3MXopQ+PcqMqXgXA83Cm kfA8/ZbSVIWE+fMGlZ3AteEDaY3gsOX4BJOvOza4zIO8hvNeb97Mmu/2WdgN0GelPN4t G8HSGF7rFI9M22zaljUMBZFxRjFcbIkKhcXRePB4VL3qTlFcV121kB9j3O4aXbjZdP/J IImw== 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=fVALPJ7omATt/ng5N+/I3De+cEI358VBPK4e/9qC8v6NULoW9/6x0V7Q0l3DBTbyEd eBCB2amEoMG8KJbbSUXE6hVmK/Dga2qoimITRUUVlcmX15h58ANRp4EfyDuv26oTIXdn MiBpWkeyvHebGSHFlBTz/Thq0Tl3pLC7zcTFYnSHaLKChUhAsAFxS6V+Zlvttr5FsIx8 3WCmNqsYs1i06FjZpstsB87wb+cJz7//toUZ7RqTb3eGWmJBFFwogKtZyqHAoh7a5leL 9QPTevZTGqOgVDem7oG9FshhbmuUnIHp76ts+wjR3jAhfYL8G1estRlEt8SG/G3qUV0w tOjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VAfYoFpI; 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 u12si17931880ilm.67.2021.05.10.09.50.48; Mon, 10 May 2021 09:51:01 -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=VAfYoFpI; 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 S238887AbhEJLUU (ORCPT + 99 others); Mon, 10 May 2021 07:20:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:52754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234026AbhEJKzs (ORCPT ); Mon, 10 May 2021 06:55:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F1CDD6192E; Mon, 10 May 2021 10:43:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643411; bh=LuLsmtNBOVUVcPlscaaqrxu62cTFLbKV2lTknh3M/k8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VAfYoFpIhCZR5iscK3RaDuDVOPOgzrsKtz65Ih64+cWBWWUgurE+rAB2rkOO6Y9my 0CPHlmq+Xb0jej5ev5mqjdXHGRG0hTx0sZZAhXW98z2nbSbc2Ww06geAn2oW963ou+ N+HgTSBEVStYj93dG+KsVoxogYl3M4W1BrlJrQ94= 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.10 277/299] media: staging/intel-ipu3: Fix set_fmt error handling Date: Mon, 10 May 2021 12:21:14 +0200 Message-Id: <20210510102014.080855817@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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;