Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2283385pxb; Thu, 3 Feb 2022 03:26:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJY0Rg3WH0e1qDoFEo6y7OAh9J4qOr5QOp6DQBcyOwMDjwE/PN1meWLXtf5xACIswoOQVl X-Received: by 2002:a63:6a46:: with SMTP id f67mr27729824pgc.541.1643887618960; Thu, 03 Feb 2022 03:26:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643887618; cv=none; d=google.com; s=arc-20160816; b=eoCeAwynslScMkGvX97TmbYKzJ9/CmBXzUdA/Immnj0DLWYYB8wRB5NOPwaxp8SKBP G9blLKIdx/Oqa4fU5Ff4A8fkKgIApbDkYZ/uOFwL2ctsB24q38JhiDc6S39TmPgWkNZI RPvZCUbcLGPZn37OtLc3X/IwsfpbzkHxhgR/jpiIZP4lDS0wSPbHEb+cbYduqxBeb2ey XpZ6gY9BOIGi2SiERIV3BWIJLlbuwwt758ixZCrmryNC+kIkbc8kKMIQgVuw5kdjZlWO aj4pdOrlEv7rcZ/pprARNIJ74xpH9gHJpBAlMLSRcTP5W7IK0XpCPm48MzytrgnS+zVh zb7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GOTW49dkatvM+333ev58XzmJGJGpPe+Z89sc7+xSJjo=; b=UMTCdBOy4dVKtc1KnzuGE++mlO5H9bKTLN+dQQd5dRl++tjt/vJ5GU2pRAejkTjNyP rzXFF0LEuEDOYZZlhEbRrSuu1tdKz2rPIky9q6xcq3/r8R/DrxumuIPzqOX4B/4rfuEM 04ayzSRsmOW67gQll2ygOhi/BxGAx0gAjsFCmk9dvFWVXLhFWBdXzsfmktaH4siXMyXr 0ng5YiV9fOZb65QFfWV2tbKEUcZRyuR80FnXpHi+GjMOiohJLW/aZB8EnfV7caIyct+a H67TvtW11YkZoYkWLEhDWRMrGNnr/u4rOW32UBFfR+BJeiZRndxIUXkxvm/S0NUapFRd IQhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wuvvP0gd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6si1691194pgc.485.2022.02.03.03.26.47; Thu, 03 Feb 2022 03:26:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wuvvP0gd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240444AbiBARNL (ORCPT + 99 others); Tue, 1 Feb 2022 12:13:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231913AbiBARNK (ORCPT ); Tue, 1 Feb 2022 12:13:10 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41868C061714 for ; Tue, 1 Feb 2022 09:13:10 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id h20-20020a17090adb9400b001b518bf99ffso3758947pjv.1 for ; Tue, 01 Feb 2022 09:13:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GOTW49dkatvM+333ev58XzmJGJGpPe+Z89sc7+xSJjo=; b=wuvvP0gdVgZs1A/Wxt5ap2DV8ui/vAGBipNuDcKGDCYcwe6WAq6sPm3j0WCUfD9Lr0 caum9JUDupSfKFFJ+B7s1kloeUVTj8qj04Ow+T34j2MeTG9JOATCNW67W9c5mk2H5Rm/ 8IWOmLnyI1OanJEtsko1eLc0Sv+iX5xstLj/NPhB3Kj1ac+IpoBtL9+60aCPgfyhuzrU 7F4xgaAChfOMtavqslzy8wfskfw8BCsf7FvCy5S1h6JimYZ3/Y47aRFe0dThCXKZ0wj2 4vdnoVu3/K1tAiQvFYZJeD56BqF1eibPvhpDsV+eX8+9vnzSKyPWLszpaLwSjmN61b4w qCRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GOTW49dkatvM+333ev58XzmJGJGpPe+Z89sc7+xSJjo=; b=df7Tq8B+wZWUePEheaEuu9oMccgGiduXdCyBunhHhky1Y01Sx2/YhkU7x/9mDdn3Rt Y9WU7bV36UCukiR590xhbJHXw6zPq54LMExju6FhTudEOeHWZ3utKBrG19UwGd8D8/+/ 20SozTsyJ8QDzHMHmQ7oxMy26uRV2df2Th/kfQC+PtwamDHy4+oQl1AhE5QVp4TfTdp+ lOdKX5mQK33b95wCSe/Z1pbBSucOyRS2s0/4v9C/ZuTtGVBiF4KBxy+EOF6ZGJcyyZay u0OAMZwlFRgVSunH4ObAZbxkHZpNAOQQjg00/gX1koC3RIXjd1ToPllOGpjVmkBPni7d ijRw== X-Gm-Message-State: AOAM530nEhYf3htlSxHNwHTNfKIjAfPWNGJeP+l9FKy+7Co6rvZ9cvoe 6axx8SwtCCR3yVKn9J6SFQ27Jw== X-Received: by 2002:a17:90b:4f4e:: with SMTP id pj14mr3422943pjb.220.1643735589737; Tue, 01 Feb 2022 09:13:09 -0800 (PST) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id 38sm32163145pgm.37.2022.02.01.09.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 09:13:08 -0800 (PST) Date: Tue, 1 Feb 2022 10:13:06 -0700 From: Mathieu Poirier To: Miaoqian Lin Cc: alexander.shishkin@linux.intel.com, coresight@lists.linaro.org, leo.yan@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mike.leach@linaro.org, suzuki.poulose@arm.com Subject: Re: [PATCH v2] coresight: syscfg: Fix memleak on registration failure in cscfg_create_device Message-ID: <20220201171306.GB2490199@p14s> References: <20220120182822.GA1342128@p14s> <20220124124121.8888-1-linmq006@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220124124121.8888-1-linmq006@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 24, 2022 at 12:41:21PM +0000, Miaoqian Lin wrote: > device_register() calls device_initialize(), > according to doc of device_initialize: > > Use put_device() to give up your reference instead of freeing > * @dev directly once you have called this function. > > To prevent potential memleak, use put_device() for error handling. > > Signed-off-by: Miaoqian Lin > --- > Changes in v2: > - simply call put_device() instead of cscfg_dev_release() in the error > path of cscfg_create_device. > --- > drivers/hwtracing/coresight/coresight-syscfg.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c > index 43054568430f..c30989e0675f 100644 > --- a/drivers/hwtracing/coresight/coresight-syscfg.c > +++ b/drivers/hwtracing/coresight/coresight-syscfg.c > @@ -791,7 +791,7 @@ static int cscfg_create_device(void) > > err = device_register(dev); > if (err) > - cscfg_dev_release(dev); > + put_device(dev); Applied. Thanks, Mathieu > > create_dev_exit_unlock: > mutex_unlock(&cscfg_mutex); > -- > 2.17.1 >