Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp99947pxf; Tue, 16 Mar 2021 23:51:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXEaE6xDoppIN7KicS98AX2apA6O+3kB9cuW+iQbhyXPy4QbZWf4zg+yy2Wga1a2/8ubVo X-Received: by 2002:a17:906:cb0a:: with SMTP id lk10mr28781664ejb.479.1615963866332; Tue, 16 Mar 2021 23:51:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615963866; cv=none; d=google.com; s=arc-20160816; b=AToJh1XY6+EgFHNcFpyI8LAYEBJ3YOdQCCyHrxyCyDi+KHyYPWqYMROz6Hs82KInfI ITW6sM1bF7+FAHYBQ4veBKtOC1N7V0Mh8ybPWHqF5o3tMZ17BYS0NFfXmjhoPBJZd+i3 u2atevBGDbadYllfzPVAJGPZb7L9e2pV1fvVjSoxs/Ld2Ab8bNGDnLhFkOQXF/i09IxC MI9OrEpuReRS1TxTgp4+U0sincaN2hoq64LF2vPFh2h7hA1OTaU+umEelBfMKIWxOZWx HL3dgaQOBu3p7X46dizyn2t8lFTnUB0oCSReqRImKTmBAmIX6tTINwFc/5dSo8Jj3AQt +RLQ== 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=fjDSU4mTmCD6NTo/1a21HELXiUYYYdWsJY8mA+WBsEc=; b=JbozpaMOOA2WxBIDWjjpZphzF8XcCXEEgDCP3cuH6N32tIMO82vK17u6s0WpQZhXKs g/sn6s0sGeX4anUi5/v6zNUpStiJZGRmAOgD4vXs+9Jb8Z3foHje5n/RfE/BP3V2Osge rZ2Elz28SHboN44pdKiSRAtZwofHirEilsLUzgnVzWty9vX0oWj9dKEtkLw4bz+maBQt aPj7muo4rYbmn4FjycqLxB2wixENSNbBq5hauCUKrveP/R0DXsGx/SKVJFvAfMYxjHFu msaTW2CHuaT+PLRDi8hR5sjRePwnNj6sLnrF4rST6MpIJ85ufbNYOL9KsXDWqNB4q89O 6mvg== 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 x27si15485169ejb.603.2021.03.16.23.50.43; Tue, 16 Mar 2021 23:51:06 -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 S229707AbhCQGtS (ORCPT + 99 others); Wed, 17 Mar 2021 02:49:18 -0400 Received: from mga09.intel.com ([134.134.136.24]:18749 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbhCQGsz (ORCPT ); Wed, 17 Mar 2021 02:48:55 -0400 IronPort-SDR: dUCstIvpElzomCFhOJK3nS5P8AQ5ot/58+a4xwtePpuXDv9fsciVzRhymApZfqo1WSt90zXH2d mvSnoTaO3a/g== X-IronPort-AV: E=McAfee;i="6000,8403,9925"; a="189495118" X-IronPort-AV: E=Sophos;i="5.81,255,1610438400"; d="scan'208";a="189495118" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2021 23:48:54 -0700 IronPort-SDR: KtHZ0CBfu/OEZrtON+eomD08mGiNPEdAGUo5sDxYKkSs3qz5Arle95r5+9m1c24soD3GQnYXVb Br/Y6cLu8OOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,255,1610438400"; d="scan'208";a="411352429" 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 23:48:51 -0700 Subject: Re: [PATCH v2 1/2] media: staging/intel-ipu3: Fix memory leak in imu_fmt To: Ricardo Ribalda Cc: Sakari Ailus , Bingbu Cao , Tianshu Qiu , Mauro Carvalho Chehab , Greg Kroah-Hartman , Arnd Bergmann , Linux Media Mailing List , devel@driverdev.osuosl.org, Linux Kernel Mailing List , stable@vger.kernel.org References: <20210315123406.1523607-1-ribalda@chromium.org> <34c90095-bcbf-5530-786a-e709cc493fa9@linux.intel.com> From: Bingbu Cao Message-ID: Date: Wed, 17 Mar 2021 14:47:48 +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: 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 On 3/17/21 1:50 AM, Ricardo Ribalda wrote: > Hi Bingbu > > Thanks for your review > > On Tue, Mar 16, 2021 at 12:29 PM Bingbu Cao wrote: >> >> Hi, Ricardo >> >> Thanks for your patch. >> It looks fine for me, do you mind squash 2 patchsets into 1 commit? > > Are you sure? There are two different issues that we are solving. Oh, I see. I thought you were fixing 1 issue here. Thanks! > > Best regards! > >> >> 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 > > > -- Best regards, Bingbu Cao