Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2549083pxj; Mon, 10 May 2021 05:42:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgY9wQdAxuAzrkHokGyJ3yW5lxos2es6/A65NqyVAnmGOpTix2jdTP+Cj8Pl0/AfaemX1u X-Received: by 2002:a05:6e02:e43:: with SMTP id l3mr21844518ilk.130.1620650541885; Mon, 10 May 2021 05:42:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620650541; cv=none; d=google.com; s=arc-20160816; b=XV421jW7qxMRQot5OsDFYY9zVhhVXFV9LfM8GJXSENXCtpMpH0GQXVe5SSnEglm/mi 5nEoM86vfFx6myhwP8Zr2Y8Tb92vMDv//atOVD+cIy/auw80o/8FXsthaaJ3l6YIgPu6 EEMF+tOClT0PR/xtN+jIu9JNqFeFwVdpcgvD4MsD0IKmzy2khMkU4Clct7BqyXOomv+q +tS7VCLrk4emdlei6vytLG5SAOvjeaCt/0Jxl02dmyXtvl/NUGq3fOcG3LmlBtK+KR46 2HWSib8wulzvqxQX0xJVflWXtIEu7ixsN4rhZHxorCccE3DnZwjx9WJ4ZCZYBLGOUnUa PqaQ== 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=eVm0oieOZnbJ7X5VRpJW4zDV9T28HmbwEqVcHzSox/CkxN+KPx9eY4d01vZ8hRb1UE JBkRspKreS7jsfiHCbESpZurObLyFwhxJASrNax7hXm7x6FkUY4PX/L0KJSCNvTwT1WD 8BSdPdlUMJm5qMjC2caVRSCR7GJsrh4YVI4xu7QxuGdZE6++5RsXuLilitxD3Gi9vU1I risX4O38AcCStV0jG0vDfF9HdXACE1wDTxqvSEtASySqKMDLihBQIniAm5LeG2N3qp+A 1LwhAizG8gt+VrweaVQL55Qvrg6he9oZyEG8MThrIx2EtxAWMMjHaL32sNNc2sqoEH8H OTyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VQOvDVLR; 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 s4si17791997ilv.33.2021.05.10.05.42.07; Mon, 10 May 2021 05:42:21 -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=VQOvDVLR; 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 S1347887AbhEJMhu (ORCPT + 99 others); Mon, 10 May 2021 08:37:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:60380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237818AbhEJLQP (ORCPT ); Mon, 10 May 2021 07:16:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6E876601FA; Mon, 10 May 2021 11:11:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620645093; bh=LuLsmtNBOVUVcPlscaaqrxu62cTFLbKV2lTknh3M/k8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VQOvDVLRbc4fkwxz0PgfldH3XqEJEqMPhoLKWZ0CIkSMMq0FUZYMSWCDTWOaRd4T+ CWmo9AmQePt6HGWf6AGTWlkQ6WQ9Y1FqrayOLXO9djcuttEnJBcm4JaulkRiNj74h6 SnCIuIqhGtHl+6Sh9DYgd0Sbc+hTKCry6O6ze/xU= 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.12 350/384] media: staging/intel-ipu3: Fix set_fmt error handling Date: Mon, 10 May 2021 12:22:19 +0200 Message-Id: <20210510102026.299359050@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102014.849075526@linuxfoundation.org> References: <20210510102014.849075526@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;