Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2232467yba; Sat, 27 Apr 2019 18:22:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+YQQ8WQ6hu4cPbRrQVlgZrMn6jgVDFB7ela08RAYoXWgySogXYCzwhDWtwwvSf66fxZXi X-Received: by 2002:a63:f315:: with SMTP id l21mr38731954pgh.417.1556414551535; Sat, 27 Apr 2019 18:22:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556414551; cv=none; d=google.com; s=arc-20160816; b=NJcAkIM1s9d3mkM9V9ngSMyvPZ52Ap0Qc1YIG6BwcdsUzSYL9aHKVPsOOiv8LJPW7C sVlUkBa2S7riS14nv1u5aUyoqR6g+uEBcjpiseN94t6NXlUoX6y11hYPgQ4w2+wSuf7O l1FAkESiLbkSBMAyR1wsjGVP3xvGA8jwdGNGQBTjFSeUHLi1fK15OANzlAUlge2sJsAd e22aCq+mfu3j4247Gzrn3+FSKBWvBa92cDPWOp0wiLrxu3UgZOTydtg3UXdoGPmFhmUf DPChxm2el98bX21cZE79lbAB5Y8q+zTNpwkgksEWOX0/UbeeF+jXrtGla7PRzaihY/Df uIog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=CaIRzs2uedsPMNBCe341n5M6L2AosQXLoInsrDXBVN4=; b=jOpfA1z5E5gRdx6LBq1fvAuV0b8xVLlNW0PYXDYDcfPb2JfnbnUnax0SAKQ3FTLytn 9y8vFbTIweyHD+aflxQogonf+8xtYaOwVb2kR0ThcdR0Gu9bVcaVwJIwn+OQqWxRZSTJ KYp9jSeqGT5bY4r6zEsipmJa+zlp3BmA43YdtD43Vs/U5qZcwSR6cqSmuIRwTs8N6pmw Pvyqkh/piCz3NKF48r7rwHhsATAp77WObaejEyuWJg/JKUH/D14i6G6VMNC3tWmdE3td dkipFz2EZgpE2baYdP9WzLgW480pWGIBLy7n84QGSq3qG3lUfNqJEPQpZGr6sZ6x4XbI eC+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tobin.cc header.s=fm3 header.b=leYrYXLv; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=MMzWaB3q; 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 k1si8186146pgs.179.2019.04.27.18.22.04; Sat, 27 Apr 2019 18:22:31 -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; dkim=pass header.i=@tobin.cc header.s=fm3 header.b=leYrYXLv; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=MMzWaB3q; 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 S1726242AbfD1BUg (ORCPT + 99 others); Sat, 27 Apr 2019 21:20:36 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:46967 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726079AbfD1BUf (ORCPT ); Sat, 27 Apr 2019 21:20:35 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id D442021E92; Sat, 27 Apr 2019 21:20:34 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sat, 27 Apr 2019 21:20:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=CaIRzs2uedsPMNBCe341n5M6L2A osQXLoInsrDXBVN4=; b=leYrYXLvCvxxjXsEvTYcOtAvGf7PeY3CZe1AJ+JrpFQ OFfkfXhhnV8noqrqdXLhh8KV2223K8dsBYuoXSuiY228TGVdD/cXQqCXQ1dhSrkr HlgC+Tt8hL/lpVUjv7OeKXYoTGuVrQZs6K2M9hoFoqIQ4tpwCkCvaOXzmDTO33Ec P/h1ndkjJFcCqBuq5i8oGmNM+qZLZkeVJeZ7iFOdnbVqpGHZ4GgN1E5G1LDpy1z2 Tcdtf8zu6FkgC82U2KxjSkdqcJXRU0SE2GGIiQer3z6ZfYa0Ac9py1l+/cjDRc9p 82VoujDQVoL80c7PC4mhx2a8jOtAK5R0zWtXRr5jAKg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=CaIRzs 2uedsPMNBCe341n5M6L2AosQXLoInsrDXBVN4=; b=MMzWaB3qAZI80xtwqm6oID SiJ89dl+AcNVPWCCrzKah9PSyS5qz4kVfBJgBUJk+YVBTljL+ic204PTBMFefbh1 3t4Uk0pRpyjrRxxkjwTDP0/3lZb48FWOxh/W15sChh2TLL/KxlXVXaKMpbXLIGhG oklIwBC71+ks4hY9NaRkgku75WNDfmX6jrj58SBfoKQN3v50+g3yDJM1AbWHBd60 1uccquwEPbePE9YOZdwccy+DUxhtB4TAH+ksN+8mGWXVA8ApjsvqjC5Wmk+HbQ0+ f3x50yflIPvdb6r/fqjFV3jSy1cisdfBXKqvC3iIR+KzqmebMVji4fQQtZVZL56w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrheelgdegiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdeftddmnecujfgurhepfffhvffukfhfgggtuggjofgfsehttdertdfo redvnecuhfhrohhmpedfvfhosghinhcuvedrucfjrghrughinhhgfdcuoehmvgesthhosg hinhdrtggtqeenucfkphepuddukedrvdduuddrvddttddrudeileenucfrrghrrghmpehm rghilhhfrhhomhepmhgvsehtohgsihhnrdgttgenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from localhost (ppp118-211-200-169.bras1.syd2.internode.on.net [118.211.200.169]) by mail.messagingengine.com (Postfix) with ESMTPA id B25DAE474A; Sat, 27 Apr 2019 21:20:31 -0400 (EDT) Date: Sun, 28 Apr 2019 11:19:57 +1000 From: "Tobin C. Harding" To: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" , cl@linux.com, tycho@tycho.ws, willy@infradead.org, linux-kernel@vger.kernel.org Subject: Re: memleak around kobject_init_and_add() Message-ID: <20190428011957.GA18843@eros.localdomain> References: <20190427081330.GA26788@eros.localdomain> <20190427192809.GA8454@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190427192809.GA8454@kroah.com> X-Mailer: Mutt 1.11.4 (2019-03-13) User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 27, 2019 at 09:28:09PM +0200, Greg Kroah-Hartman wrote: > On Sat, Apr 27, 2019 at 06:13:30PM +1000, Tobin C. Harding wrote: > > (Note at bottom on reasons for 'To' list 'Cc' list) > > > > Hi, > > > > kobject_init_and_add() seems to be routinely misused. A failed call to this > > function requires a call to kobject_put() otherwise we leak memory. > > > > Examples memleaks can be seen in: > > > > mm/slub.c > > fs/btrfs/sysfs.c > > fs/xfs/xfs_sysfs.h: xfs_sysfs_init() > > > > Question: Do we fix the misuse or fix the API? > > Fix the misuse. Following on from this. It seems we often also forget to call kobject_uevent() after calls to kobject_init_and_add(). Before I make a goose of myself patching the whole tree is there ever any reason why we would _not_ want to call kobject_uevent() after successfully calling kobject_add() (or kobject_init_and_add())? Cheers, Tobin.