Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2468872pxj; Mon, 10 May 2021 03:51:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydxE5nnoadxclhwhHOxvYNJ7uj0FRHgohU8iqSjmdZmP4k0JVMixe+/gIkK3ufC6CDBjW6 X-Received: by 2002:a92:d688:: with SMTP id p8mr20562131iln.268.1620643887197; Mon, 10 May 2021 03:51:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620643887; cv=none; d=google.com; s=arc-20160816; b=jLJOjvtsKn9Vp0A5h9Mk7ROSPh6bG6IeljzPCvokESALWLH4a/OSy5raF9zM5wG5vz yDrJfgkz12ARs/l5kCx0LeuVQC0iu65Yd5Y1GD/rQ4LhuOXVY/SuFxsAdeg+DVjh6vyy mrQ4doYTc75qA0y8N8nVxB4WJWMnHOxIBiAZqQKv2PP3noJr/sahoZo09Ka77nV/2WeJ TiiHaNLsQkVNvFToyPilRJHKcpQuhsL5mIJpZ7ThWVc8cDBDrXYs6VwUBx4fa0IVWsSb MLWQb8+jlnPx+TABAZoiFvpqmePa3OnDpfkQaQ18ueD5BpfhEQ00PQqiyYcVjPvJDdfU 5XQQ== 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=13QjJseelkez8Y+9zPdM1BmGhGILQl8hfxnWL1KMyxs=; b=lO9pPUr5qcHhNaGpL9KEnWbeVybXkmZgGaxORHWoDuky7EwuzwtvUdFqS2K3riusmS GhoC+6QUQDf3MttP56LTqqH9JPWT/5d5AUsp1LczXgyp5iEY2Idnvortp/YonG7pIizb UDrNNt5Fj4pqJ6Ug665UnH1fj4Dk/WeMan0EM47heEmOkEBdN9fpLjrF0OyqSfbpwsfG 8AryjrhyH9Mh4vCt8p/S40CtaEN62pVoYQwbyh9iYJ6UO5gLdgs75v4tyw5hNuuALgSu wHbqSAyRVdQ2AU+FmhjmYJfWIxeeYAVCozRHFe4v8TsCY9jT7u2cJP+sevCLCIp7UgeR e+OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k5jxvjRU; 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 r17si17213976iov.15.2021.05.10.03.51.14; Mon, 10 May 2021 03:51:27 -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=k5jxvjRU; 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 S233070AbhEJKt3 (ORCPT + 99 others); Mon, 10 May 2021 06:49:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:50608 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232167AbhEJKjX (ORCPT ); Mon, 10 May 2021 06:39:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8A05C616E9; Mon, 10 May 2021 10:30:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642622; bh=C+b+vsSWuCWJJ6CTAPM+d+m9+hvsejYOnu7Zxa7tkTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k5jxvjRUC8CB/hfqyjqke4EEIAVm39Zcvpsd0JAVaOW3AMfg0E/c/ehYECSvgygsK TQEKgwr0FxcwUIqsR5TJzWGFbpr1BZu/4T3Ha16j8RE2jlgdQAEkfNbzKqfCWlehbe w01BT6FzKwnpjeRr53bpd2NxIYvL9Y+C88wMpb3s= 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.4 170/184] media: staging/intel-ipu3: Fix set_fmt error handling Date: Mon, 10 May 2021 12:21:04 +0200 Message-Id: <20210510101955.687276224@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510101950.200777181@linuxfoundation.org> References: <20210510101950.200777181@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 @@ -668,6 +668,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); @@ -736,6 +737,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) @@ -743,6 +745,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;