Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp618997imm; Wed, 6 Jun 2018 03:18:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKEdvppUZRRrdThnN1RtbGmtmR5L+RcKKThNd81CBudAkI7z2DFT+CJPr1ydLRc3vo59F0Y X-Received: by 2002:a65:4502:: with SMTP id n2-v6mr2009957pgq.95.1528280314044; Wed, 06 Jun 2018 03:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528280314; cv=none; d=google.com; s=arc-20160816; b=wTbQGRdtCtSJxkXAELkESF6Q/kaZt4RBufU8ZKg+FjtwI2tYi3kt7xgRJLnlvr4dFM g87BwWAjSNCxdR8ETT7/AJKAjSoK1d4L3l5QOsmkfXLQRy33df0pC98kABQQJnm6YUNC R4VjYdG1Bw5s8aTwKAcMk0yflgVOjn3WtF9aAIZENRz1rRpE5r4NN+Z0meCHHesnBVAX zmcU2RFzltailWNWNvMHeiByZq9FFdMXx0rUgr4r+Yku7n841Xp+nl8frLw90lwSVBp8 jwH7bHx4OAyumRkyVvf0dxfD+eAa49Zr6YHZaqLPUW9bk5Rr3nyR31o34+6r3azibj/l LlhQ== 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:from:references:cc:to:subject:arc-authentication-results; bh=ZToq2fl4YWEwkh/dPu1U4TlTGheC5dMhLLMZ17bVC0g=; b=YSbu+pbxZOWsCAMLiNeolQXnz9LtXAidyM6G9kXb8BYdsOQCnu2XgE2iEDXFTvxx6p 6aSDujcpdFT2gacrc8vEi2uzpoOL+YX4MUIuuRsWjteGRXLkp3por4BnmnJMdN4qeDxh Vosw7Dq4w/HsJiRVbcgvij1Vx1D74SxeRbRKuIqWVuuiZetFGCEu6sJo2pPSY9NtgWOK aWE4ixP9dnXTTcBPd5zi/ZPVHuWbVM3u70yHF5wpVBAzVaiwT2FWoZChE7cbQaOe06NS V9Njb5uRYDD2cV/U5KdmSnoA5Wa3jC4EFXk3x3sawWtflYgfLclZnaOWfu4ogXse2KkU Gm4Q== ARC-Authentication-Results: i=1; mx.google.com; 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 p3-v6si48971551pfb.171.2018.06.06.03.18.19; Wed, 06 Jun 2018 03:18:34 -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; 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 S932428AbeFFKQX (ORCPT + 99 others); Wed, 6 Jun 2018 06:16:23 -0400 Received: from foss.arm.com ([217.140.101.70]:39036 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752243AbeFFKQV (ORCPT ); Wed, 6 Jun 2018 06:16:21 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0001615AB; Wed, 6 Jun 2018 03:16:20 -0700 (PDT) Received: from [10.37.8.39] (unknown [10.37.8.39]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 774433F557; Wed, 6 Jun 2018 03:16:17 -0700 (PDT) Subject: Re: [PATCH 01/20] coresight: Fix memory leak in coresight_register To: Arvind Yadav , linux-arm-kernel@lists.infradead.org Cc: mathieu.poirier@linaro.org, robh@kernel.org, frowand.list@gmail.com, mark.rutland@arm.com, sudeep.holla@arm.com, arm@kernel.org, linux-kernel@vger.kernel.org, matt.sealey@arm.com, john.horley@arm.com, charles.garcia-tobin@arm.com, coresight@lists.linaro.org, devicetree@vger.kernel.org, mike.leach@linaro.org References: <1528235011-30691-1-git-send-email-suzuki.poulose@arm.com> <1528235011-30691-2-git-send-email-suzuki.poulose@arm.com> From: Suzuki K Poulose Message-ID: <16154816-2760-8582-23f1-da607b344db6@arm.com> Date: Wed, 6 Jun 2018 11:16:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/06/2018 07:44 AM, Arvind Yadav wrote: > Hi Suzuki, > > > On Wednesday 06 June 2018 03:13 AM, Suzuki K Poulose wrote: >> commit 6403587a930c ("coresight: use put_device() instead of kfree()") >> introduced a memory leak where, if we fail to register the device >> for coresight_device, we don't free the "coresight_device" object, >> which was allocated via kzalloc(). Fix this by jumping to the >> appropriate error path. > put_device() will decrement the last reference and then > free the memory by calling dev->release.? Internally > put_device() -> kobject_put() -> kobject_cleanup() which is > responsible to call 'dev -> release' and also free other kobject > resources. If you will see the coresight_device_release. There > we are releasing all allocated memory. Still if you call kfree() again > then it'll be redundancy. You're right. I think it would be good to have a comment explaining this to prevent this fix popping up in the future :-). I will add it Thanks Suzuki