From patchwork Sun May 18 08:12:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haggai Eran X-Patchwork-Id: 4197611 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 23366BEEAB for ; Sun, 18 May 2014 08:11:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 491F820268 for ; Sun, 18 May 2014 08:11:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C63820131 for ; Sun, 18 May 2014 08:11:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752139AbaERILz (ORCPT ); Sun, 18 May 2014 04:11:55 -0400 Received: from mailp.voltaire.com ([193.47.165.129]:38902 "EHLO mellanox.co.il" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752124AbaERILx (ORCPT ); Sun, 18 May 2014 04:11:53 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from haggaie@mellanox.com) with SMTP; 18 May 2014 11:11:48 +0300 Received: from gen-l-vrt-033.mtl.labs.mlnx (gen-l-vrt-033.mtl.labs.mlnx [10.137.33.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id s4I8BiuA000792; Sun, 18 May 2014 11:11:48 +0300 From: Haggai Eran To: Roland Dreier Cc: linux-rdma@vger.kernel.org, Or Gerlitz , Haggai Eran Subject: [PATCH for-next 1/3] IB/core: remove unneeded kobject_get/put calls Date: Sun, 18 May 2014 11:12:24 +0300 Message-Id: <1400400746-9030-2-git-send-email-haggaie@mellanox.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1400400746-9030-1-git-send-email-haggaie@mellanox.com> References: <1400400746-9030-1-git-send-email-haggaie@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ib_core module will call kobject_get on the parent object of each kobject it creates. This is redundant since kobject_add does that anyway. As a side effect, this patch should fix leaking the ports kobject and the device kobject during unregister flow, since the previous code didn't seem to take into account the kobject_get calls on behalf of the children kobjects. Signed-off-by: Haggai Eran --- drivers/infiniband/core/sysfs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 7d3292c..1f77072 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -534,7 +534,7 @@ static int add_port(struct ib_device *device, int port_num, p->port_num = port_num; ret = kobject_init_and_add(&p->kobj, &port_type, - kobject_get(device->ports_parent), + device->ports_parent, "%d", port_num); if (ret) goto err_put; @@ -599,7 +599,6 @@ err_remove_pma: sysfs_remove_group(&p->kobj, &pma_group); err_put: - kobject_put(device->ports_parent); kfree(p); return ret; } @@ -835,7 +834,7 @@ int ib_device_register_sysfs(struct ib_device *device, } device->ports_parent = kobject_create_and_add("ports", - kobject_get(&class_dev->kobj)); + &class_dev->kobj); if (!device->ports_parent) { ret = -ENOMEM; goto err_put; @@ -876,8 +875,6 @@ err_put: } } - kobject_put(&class_dev->kobj); - err_unregister: device_unregister(class_dev);