From patchwork Sun Mar 18 07:38:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Yadav X-Patchwork-Id: 10291059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4D583600F6 for ; Sun, 18 Mar 2018 07:39:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BF3C28928 for ; Sun, 18 Mar 2018 07:39:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EE2D28E3A; Sun, 18 Mar 2018 07:39:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A2F2728928 for ; Sun, 18 Mar 2018 07:39:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=dd63wefBw+AKhWH/JL6M8vV0wsex8YfRxkcyHP+wwU0=; b=JLB yAacFhap6C7GTmFdMrH8AE8K0Xe/BZkl6cnciPDtdHwMFk5Ao41a8BrrbhLn3RzV7WxV9fOHHlXCc ovctxhNObydoYf8cC4Pa9SezckWC2MEg+hXD0ywx3jpjakJdx3fX2xG/F6exjngak4JyY7HMcZdC2 EQuGyzTR0HEPKvZilDJs1TZlssClxtj3mu8snZ56GmUsnnb9J5BFyJhMV1kF/oqTF04vSxr09na+h 5j9KxWAyNcBX7iTuWDuZgr3IyYUql0HCIhnndZvf6Vel12WtaKQ9rMQM03VD8g1u1aD7fDtTN7r4f iQrhGafe8qAjlcHVqC2eoluY7XPff9w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1exSuJ-0006dx-ML; Sun, 18 Mar 2018 07:39:07 +0000 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1exSuG-0006ca-W5 for linux-arm-kernel@lists.infradead.org; Sun, 18 Mar 2018 07:39:06 +0000 Received: by mail-pf0-x241.google.com with SMTP id z10so5804239pfh.13 for ; Sun, 18 Mar 2018 00:38:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Lt5hVgj3bdnaVs8DD4badnRvd2eYEGI3TyMi+1/YHxo=; b=XFmh/sIHtADozY35hRm+BE9DSP5e9V7EmU96W3XgKxeTp4wThiEV/arfxf3pybHtEO s6NimDFpzQPTwZhIVy7rnkC2E6a+YEDX1vy8pnqciiU5lasYO2pOhWMClfTx+c41jd2A Z2HqQdxRRnFPT6Q5VJXRk1ITx9FC1l3hsC1YoyuCgAGJbZQRII9t+OmwrDaxNf1GiO2j AWvPf79Szi76VEcSu2PVL1xMSXf/5CPCB0AWJSpn3Vhr/a28wSGwsL2UnBhAjp0UfTry 2K720C5ABjjK5OrBq8KZ7ndU8aMuPZ2aZctw8JMcP/sZ+kJh7WbjOAidJYsyLMT5gdn2 efVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Lt5hVgj3bdnaVs8DD4badnRvd2eYEGI3TyMi+1/YHxo=; b=HK/1amcLNPGCIpI0vGY32qPho1cBNc/D00EhzMShop7slTOZ9s0zk4Kv1vDfGKfxuj e0n8/C3LZA7hM6Nbd7hbYyNTD7IvNgaSHWc+pe4QvkQ8XUkOys64qqYfcdn4TqfTxa/V oZb89AXewayH0hSPQkWGE7jzliOfuNjyv4usA067DTugQu1/CmZ2/6pejs58Di9k9ce3 NW2d/uVCXOHHz6zP5qbARsfr1V6mmXozCe9TjSjcC96SzffVM+AH0LhwkqD2fyaww+yR XqSrNh5ukmCwPMv/f8j5KyVP2j7e9zZyCfChYEek2EgdZDEYL0VZxDMAoHCiVZC92EE2 uHEQ== X-Gm-Message-State: AElRT7Gl5u4uq/pALtRoGzAe/O5RzyJb+vI30nhkHo1O6g0RLCUMiVLu 3XfnuoPyp99mDpUzOPA+JvY= X-Google-Smtp-Source: AG47ELu1ml1x7L8Kl67i3Jhvxmmod0aWFlVBlkyxxPNVOKyQ1EJmp6XWZ2W1UQ89i3lD4YCIX+h9LA== X-Received: by 10.101.88.130 with SMTP id d2mr5951414pgu.383.1521358734042; Sun, 18 Mar 2018 00:38:54 -0700 (PDT) Received: from localhost.localdomain ([106.51.29.61]) by smtp.gmail.com with ESMTPSA id j185sm20178043pgc.79.2018.03.18.00.38.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 18 Mar 2018 00:38:52 -0700 (PDT) From: Arvind Yadav To: mathieu.poirier@linaro.org Subject: [PATCH] coresight: use put_device() instead of kfree() Date: Sun, 18 Mar 2018 13:08:42 +0530 Message-Id: X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180318_003905_046557_3F254ABC X-CRM114-Status: GOOD ( 12.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Never directly free @dev after calling device_register(), even if it returned an error. Always use put_device() to give up the reference initialized. Signed-off-by: Arvind Yadav --- drivers/hwtracing/coresight/coresight.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 389c4ba..132dfbc 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1026,8 +1026,10 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) dev_set_name(&csdev->dev, "%s", desc->pdata->name); ret = device_register(&csdev->dev); - if (ret) - goto err_device_register; + if (ret) { + put_device(&csdev->dev); + goto err_kzalloc_csdev; + } mutex_lock(&coresight_mutex); @@ -1038,8 +1040,6 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) return csdev; -err_device_register: - kfree(conns); err_kzalloc_conns: kfree(refcnts); err_kzalloc_refcnts: