From patchwork Mon Jan 10 07:31:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaoqian Lin X-Patchwork-Id: 12708290 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D71EC433F5 for ; Mon, 10 Jan 2022 07:32:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc: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=+/LK2sy4BVrDQLDX/XL77WwEduA6zMBAzQ8IW8pzTaA=; b=iyY3ExRT7mJzZb kc2rtwdZtlm5mOTwwH2cXtFEiq5K0VMl9MTLvhQxP8am12heXcHMYWqLMT2Y5Vx2iJpUks82SljPD FwwPYWcIP5SFCChN5DerFjxfaUX7e6WQk1npZHNoQ3abYsdsXpd2DX10wwBqy5LIIDdIk/DI3Ka2J JIu6Gw8u3vnNK4un1U5YBbJFbXo7Jbs5U9uKX8q6Rp357M1LGZvddiNN6J6kkZbZ98qy+/jwZcjIf z+ORX0810xxJ16jKIK4aq550rbyMCFrE9qo8t8ZLcoMZNJ7kW7vbYbzsKuE5Jg6ymHhEaaRZUs6xv YUYNLcIdHXFK33T3e6cQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n6p9A-009e5q-8o; Mon, 10 Jan 2022 07:31:16 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n6p96-009e3J-FN for linux-arm-kernel@lists.infradead.org; Mon, 10 Jan 2022 07:31:13 +0000 Received: by mail-pg1-x530.google.com with SMTP id f5so10414504pgk.12 for ; Sun, 09 Jan 2022 23:31:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=ocO6AD5IZFEF2fcpwCjlmCykPdbWqPQxRpQgFoAA8Yw=; b=AmTZGJScRDz3Z4ic1Kk2L/U1nJgZT8wshUfZ8ZKYhUMsfN7lcL+GqftGlit40Tb7T8 I6DiWwMI4JgBK25/vj5rSXVPuOyzYf6XxiRNxTYtz1qJooWE3e0NLEgOLO0gLGIN9iTK eWP+DDsjuJu9P2aqqrSLP0ZPG74KmNNioUjqR5YISeBKtOmgtdYnyYCaBOStESd5XNbm uJBg088HVO+P8gdBmCG3dtccuj+D4Akjfi7DyAKDilu7kEkBxc2UTzW7dQd2MMWq32iu i29akqFcm6TOLCSOKsmwd4uxhnHYIQ8JQykggsZI2N3so+DuMwQIp9F4o6tsattnq3xY FYMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ocO6AD5IZFEF2fcpwCjlmCykPdbWqPQxRpQgFoAA8Yw=; b=1xy2kj/TVZXCSngg2wgYjp9n+Z1RqMgh4dmvI97NqD1X3NCEUpVwH1NS9fJDSKf5AH FMm2DinqdDxkzhXwTzsShiaoA+RqHuDEmjT0Z0ykv4nEHcRnlZFq1N3FUZ/qbh3nkVWc wwm7XWrKLV7PAxTgKYBB0NNgMzmoEdVcBZVVJRtw6YoNHCJWkzk23bvjOafZcSjtKnMY W+E3JEdasti8fBwxAgsEGY06PjvpDPvsGK1ghC69qRyKeVI5DjZt+llcMumxIp+i7CXk EtX8Py0gfZqWzqwHqr0x8wxFMLLRi3hBTTc3WA+OwQYDG92OLGMHXGh8a2haps969lu+ SXkQ== X-Gm-Message-State: AOAM531qqdJxVHReVTKeg33rmNk+NALuRZZ1YwPGnGSIvWR7Fwq3k+Kg 2ycp9zZKvVsNhyKWw+Rip5I= X-Google-Smtp-Source: ABdhPJwNd99kMRjYeM+oFG8pgS4dz7JV4lfXvkTzZatdQflIwOFGgDZfZMi9isMQUl4DMGnaRzF6+Q== X-Received: by 2002:a63:741c:: with SMTP id p28mr1818794pgc.277.1641799868416; Sun, 09 Jan 2022 23:31:08 -0800 (PST) Received: from localhost.localdomain ([159.226.95.43]) by smtp.googlemail.com with ESMTPSA id w2sm4604589pgt.93.2022.01.09.23.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 23:31:08 -0800 (PST) From: Miaoqian Lin To: Cc: linmq006@gmail.com, Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , Alexander Shishkin , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] coresight: syscfg: Fix memleak on registration failure in cscfg_create_device Date: Mon, 10 Jan 2022 07:31:00 +0000 Message-Id: <20220110073100.15497-1-linmq006@gmail.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220109_233112_544510_0399AE83 X-CRM114-Status: GOOD ( 13.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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() instead call kfree directly. Signed-off-by: Miaoqian Lin --- 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..007fa1c761a7 100644 --- a/drivers/hwtracing/coresight/coresight-syscfg.c +++ b/drivers/hwtracing/coresight/coresight-syscfg.c @@ -764,7 +764,7 @@ struct device *cscfg_device(void) /* Must have a release function or the kernel will complain on module unload */ static void cscfg_dev_release(struct device *dev) { - kfree(cscfg_mgr); + put_device(dev); cscfg_mgr = NULL; }