Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3256449pxf; Mon, 15 Mar 2021 05:36:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKCB8LYyPYQsyziEz1KeHIBTd1+59rYfNDl//G8VjUkXvtBVdXWsrCCcdvs6vbGqoTv+Fn X-Received: by 2002:a17:906:789:: with SMTP id l9mr23039952ejc.161.1615811781675; Mon, 15 Mar 2021 05:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615811781; cv=none; d=google.com; s=arc-20160816; b=h8K5k0dD3806REDFGGlqrE6uTlkRnL+d60xHbQ3+Y2/hrNgbH97TOInMUB/PtQ3o6E kAVIhSJ2+SHKkQBRbc5tEMhnpFtkMJdHoOm/mk5T2EVwhiHRvs4tg0TR0GRBckhYsI5S IuipNGXoR8ke61QAc1L6rol9iSTDuOIQxmYH33xc1Cqt2rCm5IqbR6UE1aop/jNqXmKu bLpdauMoPLo5AELu2+8Q+eRnv9EdoHdsZxZr/U8uyEFm5ntVGHtNbQD770gzygsLPsPL 95PWYwqayeA9a0RAe7vWhMJadX2RPPcl+Uyufu/7NmIPMbIRjA9U4UAwyKHkhZAt9iTS wdlA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6fzzF2nTd+REl5qE5E9llLopvCzR8WvhV0GzxYvbKiQ=; b=m6xV0Kyf6T2lcU62JnGqtonMGS4qBv/OCXiygHeypxdRTGxBQlsNCJERkSVcYDjU/9 Ux9kUmyufGCFxZP8WnkBzbg1eVOOq1givNJ1AAe17Y50Jc7GXxa8tCg+7PtVXI0ORliV abZwzBX+cRusOspVoZmgf9JYpLpLx0T53iSFoeIKsLW0JNVy5aK2vaNvWRGxWCAor+xM jGsBxLwzgxz8/JqD55xR7Tave/y7Zu9TEUwjlgjmfhn03xwoR/Cre3xJRdWIPpPzpbFM KH3YtzewNm/yYVAElxSKWrYdX67xk4kk/CT4A9IV9M04KeJkZeltsjCjTJkGwJMSmAk+ F+kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hoyWYL6U; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p25si10628590edm.297.2021.03.15.05.35.59; Mon, 15 Mar 2021 05:36: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=@chromium.org header.s=google header.b=hoyWYL6U; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229720AbhCOMeh (ORCPT + 99 others); Mon, 15 Mar 2021 08:34:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbhCOMeL (ORCPT ); Mon, 15 Mar 2021 08:34:11 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D95FC061764 for ; Mon, 15 Mar 2021 05:34:11 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id jt13so65940092ejb.0 for ; Mon, 15 Mar 2021 05:34:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6fzzF2nTd+REl5qE5E9llLopvCzR8WvhV0GzxYvbKiQ=; b=hoyWYL6Ua5bHjZ5fFiNjWiTwgVHOeBMTl+C5u13Hz9ANPNeqiQqB5bdkXQOvPxa4JC TXZrjnLLJzAUkFsn3tNWaX8h3rYBk90pIGTe4hmFG7FsbEsYNyD8330Qq0UeAvATAY2r OAS+nnMyIWc8xYtIds8GqZY6O2L+O+c43FTIs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6fzzF2nTd+REl5qE5E9llLopvCzR8WvhV0GzxYvbKiQ=; b=fPukVxET/Kgj+EN0VBjefTkmL2su+eGiRq7BLoPmYCbCNfOiCErGMCH03j3bFFWdmE qUaE/lyZSidly2IfO+ZI/hpN1rW4EVhdfCqTWNWH6QRFTUp5XFimCI0DoVmkT1K+yIB3 DyAuJmaW8rDEMhTNq8j9da10m3YHWc/bJz7Q6uca4vpGOeNc3B7VVx5QeBUL++dSOJTd j606SxLB3ZY81wPg9ey+HEdqe3B+lAtm4eiC0GE8pXAqcsXHCXcKd4XdzYEviyO2h8Fp dG7NGuhl57qlfvvs2Fs/XACnHoxmv8fPl4yLzFWsH6WDqy/6SbEzFmPh2O5ietHOJi+D yAiA== X-Gm-Message-State: AOAM531aAhBlgr1PztDSVbIRy0Dg2PNAKtCVQ1rpgaM+DIEELcGI0XeY VR2+LrQa2ei7ssHcYIBOA20CzA== X-Received: by 2002:a17:906:b297:: with SMTP id q23mr23580704ejz.315.1615811650164; Mon, 15 Mar 2021 05:34:10 -0700 (PDT) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id p3sm7155128ejd.7.2021.03.15.05.34.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 05:34:09 -0700 (PDT) From: Ricardo Ribalda To: Sakari Ailus , Bingbu Cao , Tianshu Qiu , Mauro Carvalho Chehab , Greg Kroah-Hartman , Arnd Bergmann , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda , stable@vger.kernel.org Subject: [PATCH v2 2/2] media: staging/intel-ipu3: Fix set_fmt error handling Date: Mon, 15 Mar 2021 13:34:06 +0100 Message-Id: <20210315123406.1523607-2-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210315123406.1523607-1-ribalda@chromium.org> References: <20210315123406.1523607-1-ribalda@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If there in an error during a set_fmt, do not overwrite the previous sizes with the invalid config. [ 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 --- drivers/staging/media/ipu3/ipu3-v4l2.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c index 35a74d99322f..6d9c49b39531 100644 --- a/drivers/staging/media/ipu3/ipu3-v4l2.c +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c @@ -686,6 +686,7 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node, dev_dbg(dev, "IPU3 pipe %u pipe_id = %u", pipe, css_pipe->pipe_id); + css_q = imgu_node_to_queue(node); for (i = 0; i < IPU3_CSS_QUEUES; i++) { unsigned int inode = imgu_map_node(imgu, i); @@ -700,6 +701,11 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node, continue; } + if (i == css_q) { + fmts[i] = &f->fmt.pix_mp; + continue; + } + if (try) { fmts[i] = kmemdup(&imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp, sizeof(struct v4l2_pix_format_mplane), @@ -728,16 +734,10 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node, rects[IPU3_CSS_RECT_GDC]->height = pad_fmt.height; } - /* - * imgu doesn't set the node to the value given by user - * before we return success from this function, so set it here. - */ - css_q = imgu_node_to_queue(node); if (!fmts[css_q]) { ret = -EINVAL; goto out; } - *fmts[css_q] = f->fmt.pix_mp; if (try) ret = imgu_css_fmt_try(&imgu->css, fmts, rects, pipe); @@ -748,15 +748,18 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node, if (ret < 0) goto out; - if (try) - f->fmt.pix_mp = *fmts[css_q]; - else - f->fmt = imgu_pipe->nodes[node].vdev_fmt.fmt; + /* + * imgu doesn't set the node to the value given by user + * before we return success from this function, so set it here. + */ + if (!try) + imgu_pipe->nodes[node].vdev_fmt.fmt.pix_mp = f->fmt.pix_mp; out: if (try) { for (i = 0; i < IPU3_CSS_QUEUES; i++) - kfree(fmts[i]); + if (i != css_q) + kfree(fmts[i]); } return ret; -- 2.31.0.rc2.261.g7f71774620-goog