Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4846310yba; Mon, 13 May 2019 00:15:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9TbHG6E+HkxFEHp5FLzDT42lNek70CRzTocs8pZPjYZewomIXTaVTQYWA1S9wNVSoRK4E X-Received: by 2002:a17:902:5a07:: with SMTP id q7mr29032128pli.287.1557731741782; Mon, 13 May 2019 00:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557731741; cv=none; d=google.com; s=arc-20160816; b=XxmWn7WDJFUbJwJ7IJMCEs2bu5Ft5P7wCR3fC7KAEDBjgEOl1romAltKBr3B8G/Mnx xZdUYUYOGpBG/AOo/ZEYiZ49ge8mClLKF8It0XjU6POURyRVgH8Y29aE8J85nNGt3rSv rH5tibbKqo5THEr0kM6vcNKqsyCa7Xx3BVd6Bf40cTcBZHgLm9e8270kWFQL5ngXTbb1 IabOrrY4tVMyWjEc2X5bTi6HJcN70zfpG1WgSeIrKSOUP+a11s3wmJdWiigb7ogmcH0J qUeKulI/aVjC1WTtpdO5pcn8W5IjFJceLTzQp4eT9+AGCZOYZK499m+UNv1lO+E4nA/O FkKg== 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; bh=WXVW8dQ/QPds2VXy2HZoITwVucRbZTWOQwO0Y8VnCUI=; b=qKRO0q/5DrFRLmTaNAgM44J/uMGLgge23A+OCYIKMNVoh0gDalBsdWhz3uXlXXncXN mbSgKENnrTzYNnvgCzirtET7y9yuO8OpFSsk4NbLy4ppSC6Ravyp8EYEJkFdGfk9sbAk zLbEKmwag1jluK8JrNaGeyWB0Xi6Lc5NncMbBWiItUAwTf3QkrMIp5bowM1Dx7aPVBVO 2uAVQZRbSUOjTKDry9uaIbr1jmq7pDqyQ7hiBRnvP3p7E3H18dQc7XSNWKDhXdwD9Q02 ieLo9wgVQHAPKLxrVkxPcetuPokK5SoNrMbLiKSjZ3HdAPhLkHWpnfOYfix5Kq/JDPz8 8d/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Y/4vKkRQ"; 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 e1si16199044pln.52.2019.05.13.00.15.25; Mon, 13 May 2019 00:15:41 -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=@kernel.org header.s=default header.b="Y/4vKkRQ"; 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 S1727908AbfEMHOI (ORCPT + 99 others); Mon, 13 May 2019 03:14:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:34124 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727791AbfEMHOI (ORCPT ); Mon, 13 May 2019 03:14:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 259EC20578; Mon, 13 May 2019 07:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557731647; bh=u0FJlBS537HaHJw+5yUJoZ5Nb1A7lrTHIbeNy8X65VY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Y/4vKkRQDVcgIpYrWEF7EXcG2x7CttfLYu4G55iSSZHUOy2F0Ihc27KfO9Xc9KOqb yAySn/OXtNG9O4vj8wHogZYBawVcLTQOJvabbTYMpjECsCec8HjIadxTBV3Ayn4X71 KPQe9NGkr5e0Yna8ZFsKJgekUlzBQPZUTK3aajDs= Date: Mon, 13 May 2019 09:14:05 +0200 From: Greg Kroah-Hartman To: "Tobin C. Harding" Cc: Bob Peterson , Andreas Gruenbacher , "Rafael J. Wysocki" , cluster-devel@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] gfs2: Fix error path kobject memory leak Message-ID: <20190513071405.GF2868@kroah.com> References: <20190513033213.2468-1-tobin@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190513033213.2468-1-tobin@kernel.org> 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 Mon, May 13, 2019 at 01:32:13PM +1000, Tobin C. Harding wrote: > If a call to kobject_init_and_add() fails we must call kobject_put() > otherwise we leak memory. > > Function always calls kobject_init_and_add() which always calls > kobject_init(). > > It is safe to leave object destruction up to the kobject release > function and never free it manually. > > Remove call to kfree() and always call kobject_put() in the error path. > > Signed-off-by: Tobin C. Harding > --- > > Is it ok to send patches during the merge window? > > Applies on top of Linus' mainline tag: v5.1 > > Happy to rebase if there are conflicts. > > thanks, > Tobin. > > fs/gfs2/sys.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c > index 1787d295834e..98586b139386 100644 > --- a/fs/gfs2/sys.c > +++ b/fs/gfs2/sys.c > @@ -661,8 +661,6 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp) > if (error) > goto fail_reg; > > - sysfs_frees_sdp = 1; /* Freeing sdp is now done by sysfs calling > - function gfs2_sbd_release. */ You should also delete this variable at the top of the function, as it is now only set once there and never used. With that: Reviewed-by: Greg Kroah-Hartman