From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9365C433E6 for ; Tue, 16 Mar 2021 17:51:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 858846512F for ; Tue, 16 Mar 2021 17:51:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233674AbhCPRvJ (ORCPT ); Tue, 16 Mar 2021 13:51:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233139AbhCPRug (ORCPT ); Tue, 16 Mar 2021 13:50:36 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 576EDC061756 for ; Tue, 16 Mar 2021 10:50:35 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id f10so13498054ilq.5 for ; Tue, 16 Mar 2021 10:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JtrNAHIlNGqyu7tY2KgHDa90TRR2iABoGQSIvstGdZs=; b=kN4jETKpOsMT8ujABTKX/KoA1MUTlDRb+Z9NHUYVnpAh0syYrBtdaNgzA3IIHB602i HsTlTbMAjEyLIPblDWQdvaFB6Q6U8xj7Wm6Qa/UJmkrU/ZRuins9KWZSKS1KwDBsxG0K uk71bJAwFyqxS1ex5mOipRhoh7DVGXgqio8WQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JtrNAHIlNGqyu7tY2KgHDa90TRR2iABoGQSIvstGdZs=; b=gBiU8gBPLj2/GWH5m1Jz2wkxwAkR0AmVa3R8XRVbYqYQktsEn4uPnZqvWpqHmC4RJY CVQK9MXZBGXzjkn/mP3j6IVXyr5KhRIM7oLIXkvyhwtpE8HzbjZ8nYzAdLblS+OctyAB wPZJ2w4WqRRsLj++RUtfMU+vBmzNfuuUKWbe6D/8PY0B8lS9vJEQYWEI5FHPXKUn0Zmf xhJL8yx9iTx9USdGAH3zkgnawq8BSK1sTWDMB5xmFgu6hBU/EPxKgR0O1Q9JUYvDUjZy 7e2AHRV/M+KFl5RfH0oc+hOJGnOUsmlzwyTYLAlUGYlNdUbMuWsbA4OgTj8Iqm84hJ98 XuqQ== X-Gm-Message-State: AOAM530GiCVo5PLUq1GiHt2qUKi1NP+8j6NnQZNRdvWoLI/OXlrX7KjO YHz3Zt0L6O4exetfVzEF9HHDyNPq/QeClw== X-Google-Smtp-Source: ABdhPJx3jNSKWyMKGoAfd/07MSeXlLqkuN/c5kV7cTMm07q6XgC7HqnfPrnM377tkhhCwipUC7vWLw== X-Received: by 2002:a92:cda1:: with SMTP id g1mr3205483ild.141.1615917034520; Tue, 16 Mar 2021 10:50:34 -0700 (PDT) Received: from mail-io1-f52.google.com (mail-io1-f52.google.com. [209.85.166.52]) by smtp.gmail.com with ESMTPSA id b12sm9760065ilr.55.2021.03.16.10.50.32 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Mar 2021 10:50:33 -0700 (PDT) Received: by mail-io1-f52.google.com with SMTP id 81so38104172iou.11 for ; Tue, 16 Mar 2021 10:50:32 -0700 (PDT) X-Received: by 2002:a02:cb4b:: with SMTP id k11mr15230940jap.144.1615917032400; Tue, 16 Mar 2021 10:50:32 -0700 (PDT) MIME-Version: 1.0 References: <20210315123406.1523607-1-ribalda@chromium.org> <34c90095-bcbf-5530-786a-e709cc493fa9@linux.intel.com> In-Reply-To: <34c90095-bcbf-5530-786a-e709cc493fa9@linux.intel.com> From: Ricardo Ribalda Date: Tue, 16 Mar 2021 18:50:20 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] media: staging/intel-ipu3: Fix memory leak in imu_fmt To: Bingbu Cao 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 -- Ricardo Ribalda From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C79FC433E0 for ; Tue, 16 Mar 2021 17:50:39 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3175365120 for ; Tue, 16 Mar 2021 17:50:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3175365120 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id E092A414EF; Tue, 16 Mar 2021 17:50:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MgDKmNnJTq7J; Tue, 16 Mar 2021 17:50:38 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id D4A9742FFD; Tue, 16 Mar 2021 17:50:37 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id F1B401BF427 for ; Tue, 16 Mar 2021 17:50:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E0BE182883 for ; Tue, 16 Mar 2021 17:50:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uxpeGfCnSDOl for ; Tue, 16 Mar 2021 17:50:35 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by smtp1.osuosl.org (Postfix) with ESMTPS id 35A5582404 for ; Tue, 16 Mar 2021 17:50:35 +0000 (UTC) Received: by mail-io1-xd33.google.com with SMTP id o9so38135568iow.6 for ; Tue, 16 Mar 2021 10:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JtrNAHIlNGqyu7tY2KgHDa90TRR2iABoGQSIvstGdZs=; b=kN4jETKpOsMT8ujABTKX/KoA1MUTlDRb+Z9NHUYVnpAh0syYrBtdaNgzA3IIHB602i HsTlTbMAjEyLIPblDWQdvaFB6Q6U8xj7Wm6Qa/UJmkrU/ZRuins9KWZSKS1KwDBsxG0K uk71bJAwFyqxS1ex5mOipRhoh7DVGXgqio8WQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JtrNAHIlNGqyu7tY2KgHDa90TRR2iABoGQSIvstGdZs=; b=cRDFqLaIIH2fV0hW+LTxuhNJFw9KoFD9QHsfv8y/yMlW9c8nr0z4N+5O1IMC3iYX79 vw1fuPFZUIXOBy1oH1drCG0sripp8jTqr1EvpAbLhalAfi+OoH3ppOam2pmT0gAh9nJ9 iRWp60vXeaghhhi7nHdW3BATX5sNc3ZMEJu4tNILDivIFTTTM2zJ46DxCtwvjEmJ1PsW 85FdZmfsFXLpFc8zjso56IXn4eAaFqGlP1jXUoRfOi+vQfeHpRHkr6vp8N2OA6gjt+R1 C9031Qpzja7xYaDSLA6E9/M2ffleMl3h5y8MWvr2VoUbAl67xjDrnwrJSCYrbocQJWLL YfIQ== X-Gm-Message-State: AOAM5313fL/es5zv2Ho8mXXFOcQwbY74wgTOUfbE15cANRXYC4n4qy2L GRTL0fOFQ4+TBmV1JU0u6J7pidid9sH2NQ== X-Google-Smtp-Source: ABdhPJzCIuueTb3rtXsPvwql1s2KJdUG5Kh/l5BmSKL8yjdDAoTypOyUwjnAiennhk5WtuDejH0GtA== X-Received: by 2002:a02:ccd9:: with SMTP id k25mr13906223jaq.43.1615917034079; Tue, 16 Mar 2021 10:50:34 -0700 (PDT) Received: from mail-io1-f50.google.com (mail-io1-f50.google.com. [209.85.166.50]) by smtp.gmail.com with ESMTPSA id j14sm9344103ilu.3.2021.03.16.10.50.32 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Mar 2021 10:50:33 -0700 (PDT) Received: by mail-io1-f50.google.com with SMTP id w11so12355442iol.13 for ; Tue, 16 Mar 2021 10:50:32 -0700 (PDT) X-Received: by 2002:a02:cb4b:: with SMTP id k11mr15230940jap.144.1615917032400; Tue, 16 Mar 2021 10:50:32 -0700 (PDT) MIME-Version: 1.0 References: <20210315123406.1523607-1-ribalda@chromium.org> <34c90095-bcbf-5530-786a-e709cc493fa9@linux.intel.com> In-Reply-To: <34c90095-bcbf-5530-786a-e709cc493fa9@linux.intel.com> From: Ricardo Ribalda Date: Tue, 16 Mar 2021 18:50:20 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] media: staging/intel-ipu3: Fix memory leak in imu_fmt To: Bingbu Cao X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Arnd Bergmann , Greg Kroah-Hartman , Linux Kernel Mailing List , stable@vger.kernel.org, Sakari Ailus , Bingbu Cao , Mauro Carvalho Chehab , Tianshu Qiu , Linux Media Mailing List Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" 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. 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 -- Ricardo Ribalda _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel