Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp721683ybl; Wed, 21 Aug 2019 04:41:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwplIbWkwRpx/sW4EGXM7H52ifGhWRNUoO8cyjuaXCwTziKVt2yRYGR0+aoI1zWZwRwrJ51 X-Received: by 2002:a17:902:a607:: with SMTP id u7mr33585409plq.43.1566387699129; Wed, 21 Aug 2019 04:41:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566387699; cv=none; d=google.com; s=arc-20160816; b=wD4wJE5A0sb6rhlEAz7nA+Ric234Vu4pXsa4OmU8Q1nExTktWtqGEAlvkpnbUa2qN+ PyIy/x7oDZGlLUSdK+wDTywObcdyUo9iIQqjCItmLahry6ZinhZuuEOyoKlGmgjzGIhe Qrkq0L4QNxzAdfWQywvql1jy/TDmmn552alKFzH1o6a5PlgOCuDbMrBRfnFQvh/ferII okgTD6BJH8zfb6Xj7miJhCmMzRoj/GbZUJl6tZj2uYOoo0SR8GF2VOm0MjZXTzkqWPEb lnMSqlp9Az+6jpf4NGG02k6CMrRZX4X6gRerg/vf+7OvrXayZBQzfmsqWNW7C2MS3Rvc g53w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject:reply-to :dkim-signature; bh=rznhfBEKCggj+Qn1ZjmLC3xWFGUwaE+eIy/ZsSwGRSY=; b=UySkyJ4T7CP6OumFG7YFBOKhRAzLhUSL0HFm27zpfYMsjhrsQ+GMlLrsnoylmYF+sK sEdbi3x4WkGnqB6MRyKcIoU48Ji85zyH8wtRErAVFs8rXQ9xLKwmwlOs1h8cHaxamI8q NuDT/xWscmb8hAcAUKxUFTaGGetmS6p3O3KyylHhA+jK2U0vTmBbxpTE8pi3JPqt28Fp 6fKIeRDzkH5Xhrc/A8IZBwwPcyqDWGQyUP+8SE/vGRN8tAuFW8NYUHaUwxovNYx6K6Sy qumrMBLTy0UTP0bwlcJ1R1y91CjW3iBZM/ee2m8dI2a4VBOkxFKfDQKA7/7UfAqWVqWX Qu2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=vcFH3PmA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l3si2087071pju.85.2019.08.21.04.41.22; Wed, 21 Aug 2019 04:41:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=vcFH3PmA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727210AbfHULjZ (ORCPT + 99 others); Wed, 21 Aug 2019 07:39:25 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:55264 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726372AbfHULjZ (ORCPT ); Wed, 21 Aug 2019 07:39:25 -0400 Received: from [192.168.0.20] (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6C10333D; Wed, 21 Aug 2019 13:39:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1566387562; bh=GAq+49gNlQ0+5jt+SnoVFQqH/A1hRnn5GfyLB3dQbN4=; h=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From; b=vcFH3PmAnGrWXhHSjA1SmeQRQWfYz80wcYJuTJIuh3UeYf/tFHYuut0fHVFJV26Sf 3ZwttZtDBI6IEBH64/zVrXakvfHAL5BIt9nm6ypygtYq1hTdnL1+qfMXbSXojmUPuo H2eN8cGGB7s8TPr3Ut51aJu60TNTPVdNpvBk9/9Q= Reply-To: kieran.bingham+renesas@ideasonboard.com Subject: Re: [PATCH] media: fdp1: Fix a memory leak bug To: Wenwen Wang Cc: Mauro Carvalho Chehab , "open list:MEDIA DRIVERS FOR RENESAS - FDP1" , "open list:MEDIA DRIVERS FOR RENESAS - FDP1" , open list References: <1566107933-3355-1-git-send-email-wenwen@cs.uga.edu> From: Kieran Bingham Organization: Ideas on Board Message-ID: <5cb18e08-4e9b-6ca4-015a-fb21b4f7d504@ideasonboard.com> Date: Wed, 21 Aug 2019 12:39:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1566107933-3355-1-git-send-email-wenwen@cs.uga.edu> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Wenwen, On 18/08/2019 06:58, Wenwen Wang wrote: > In fdp1_open(), 'ctx' is allocated through kzalloc(). However, it is not > deallocated if v4l2_ctrl_new_std() fails, leading to a memory leak bug. To > fix this issue, free 'ctx' before going to the 'done' label. We could also free it up in the error path, with an if (ret) kfree(ctx); and remove the kfree which is in the "if (IS_ERR(ctx->fh.m2m_ctx))" check. But I think that doesn't gain much really. So this is ok by me... If you prefer that method, then feel free to submit a v2, Otherwise I think this is fine: Reviewed-by: Kieran Bingham > Signed-off-by: Wenwen Wang > --- > drivers/media/platform/rcar_fdp1.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rcar_fdp1.c > index 43aae9b..9e4b330 100644 > --- a/drivers/media/platform/rcar_fdp1.c > +++ b/drivers/media/platform/rcar_fdp1.c > @@ -2122,6 +2122,7 @@ static int fdp1_open(struct file *file) > if (ctx->hdl.error) { > ret = ctx->hdl.error; > v4l2_ctrl_handler_free(&ctx->hdl); > + kfree(ctx); > goto done; > } > >