Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4233906pxf; Tue, 16 Mar 2021 08:36:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5RULj0cQryEQqwJvegrDzar7fmrP12kx1Bau0nkH86NdYNSS1ohFwYOA/LMiBQrYvHhmM X-Received: by 2002:a05:6402:1cc1:: with SMTP id ds1mr36131887edb.135.1615908972423; Tue, 16 Mar 2021 08:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615908972; cv=none; d=google.com; s=arc-20160816; b=dzAArOXjBM5w2Vskhb1k10/gvL1MxOn6OPwrB4tKCkGx7D5IqEjpiPSE49z/k+P+gZ YTYsTdaZQC1cUNfvX/xsorvgWvZVx9P2rvQkQafYi0W36LYro54yaBxfFAkNz1ld/Hiw 6vbBX2u6xhnaIA2wdxAfgn46+kwM8x+x35ntriyZWF+4GA0aOQ/VI//odMA2AzIJHNiK /ggUKFpQjX7eHZR3IfJ6vsQeQG2cxWC/nFYVuzRoAS+TglWbG2kN6aF4ptrkNjqaq7hI h7KpPzXJmZ6Imx3g75vJkATs1UnXOn17c5bnO6BTjwJguJW7gZ2LkVE2wHtrpfYdvnr9 nVSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=4kemgIYmRoYs4J6uNG6t1aVoBEZmIab7QyY1UFBe1yk=; b=ofSkDZvOiTOYu1X1B1F19xZBJzIK+hTXiJ2ChE+lEJfqxKStKVdX93olPjfYZiE0qR AAjtZ77c77wGjB5K9+a5uRpW71yPd9fx1dRSXLMVwbqG8XYDQL/YHuUafUZet3xl+DhN EpuSC/rD1ctUqCC7DHf/my8JYHVARzXyBVN/qe8bfquVBHZa0n0W9CW/mk3p5tkfpbgy 5DiL6zVTcRoJDtCurp1ufhip8EIKb8mWz0aaujlaZiSsmeenwf0UO08Ip6oRXYSlEppj gWe/OOxdUtuRcwpZaE7NKPWtIvmPQfH3mbUtaBc6rxoH3uigT7S2jTYVnO4Jt5e13Rb/ RhUw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b67si15291344edf.490.2021.03.16.08.35.49; Tue, 16 Mar 2021 08:36:12 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234264AbhCPL30 (ORCPT + 99 others); Tue, 16 Mar 2021 07:29:26 -0400 Received: from mga17.intel.com ([192.55.52.151]:4081 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234538AbhCPL3G (ORCPT ); Tue, 16 Mar 2021 07:29:06 -0400 IronPort-SDR: o7nvgtrmyM3ZPCofWZvYYE3ZInSyE6gP5bvi6TeJhSoAxXgCfV4X2yt8Ok9fxw9so/56Cs8Rdo xS91BA3FTr+A== X-IronPort-AV: E=McAfee;i="6000,8403,9924"; a="169158043" X-IronPort-AV: E=Sophos;i="5.81,251,1610438400"; d="scan'208";a="169158043" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2021 04:29:04 -0700 IronPort-SDR: rU0cdm0KON0LGWPyAtiNF90Ez+rLD7hoRZU/DnajYX4Ldn8a4NgoyrTFW2dKeBVDEtghHoyaay 9o5s54ypAwcA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,251,1610438400"; d="scan'208";a="411018912" Received: from ipu5-build.bj.intel.com (HELO [10.238.232.196]) ([10.238.232.196]) by orsmga007.jf.intel.com with ESMTP; 16 Mar 2021 04:29:00 -0700 Subject: Re: [PATCH v2 1/2] media: staging/intel-ipu3: Fix memory leak in imu_fmt To: Ricardo Ribalda , 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: stable@vger.kernel.org References: <20210315123406.1523607-1-ribalda@chromium.org> From: Bingbu Cao Message-ID: <34c90095-bcbf-5530-786a-e709cc493fa9@linux.intel.com> Date: Tue, 16 Mar 2021 19:27:56 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210315123406.1523607-1-ribalda@chromium.org> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Ricardo Thanks for your patch. It looks fine for me, do you mind squash 2 patchsets into 1 commit? On 3/15/21 8:34 PM, Ricardo Ribalda wrote: > We are losing the reference to an allocated memory if try. Change the > order of the check to avoid that. > > 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 | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c > index 60aa02eb7d2a..35a74d99322f 100644 > --- a/drivers/staging/media/ipu3/ipu3-v4l2.c > +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c > @@ -693,6 +693,13 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node, > if (inode == IMGU_NODE_STAT_3A || inode == IMGU_NODE_PARAMS) > continue; > > + /* CSS expects some format on OUT queue */ > + if (i != IPU3_CSS_QUEUE_OUT && > + !imgu_pipe->nodes[inode].enabled) { > + fmts[i] = NULL; > + continue; > + } > + > if (try) { > fmts[i] = kmemdup(&imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp, > sizeof(struct v4l2_pix_format_mplane), > @@ -705,10 +712,6 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node, > fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp; > } > > - /* CSS expects some format on OUT queue */ > - if (i != IPU3_CSS_QUEUE_OUT && > - !imgu_pipe->nodes[inode].enabled) > - fmts[i] = NULL; > } > > if (!try) { > -- Best regards, Bingbu Cao