Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5529606yba; Mon, 13 May 2019 12:28:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0lwHszR+LaDux8ZXOGtxGp2wKzFZ9Et3HeHjUgo+T+fOPycjpiK3oZtNnkUoqnRy6/LLJ X-Received: by 2002:a63:3182:: with SMTP id x124mr32774412pgx.364.1557775736816; Mon, 13 May 2019 12:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557775736; cv=none; d=google.com; s=arc-20160816; b=R9mJCXW9p/PPbZ5TdXXRWDDgo4dyD7qDTarVi34L9yhEEeL5UrJB/xNdjaePGWtXCK XeOAy5pYjN8M4Iqi54wVHBgbKlSPgcfr5hFKoVO7xQwjuXISMftsoZk7y/cE8P0BWrgl Htne+DwU1gBJi2wp/x5dZ2KHLsIvD0dGe8amJuVGBSIHe7if94U2jNfG5nsCtr63V4fb V08AqpJ+NYgG8cAQfAoSg/fpSylMCn6pz+7BuPVdfkdR3BOyEmN1+nFMSbs+b1y7CpXl GWVotdQXCATktxRs9unJzNWnneAchz3eJdf9kCEUHUCTz/dzscURu9PwHCBlscwV9DWh SeAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=DTPzcVxKVm0Pc29DEn3cmhWP30Ec3xr80gOHbyh3pg4=; b=gMgBFaPP9eliXpdVlM+0kSECJBQZWjDO+7C/j4e7zs8dun2UsDdqvrKQq4EGhIVZ0f IMLj4t24Ki1q71mnE4hvWI5zoYTyX9CUXXFxbVcMthaUuZDWYDnG7zyB+HdxNRMphObx WpSQ/nSThzuH7gIH4BNXNvUqNXzo6KGhl9Ba3E3CYGKTWNas3cpPiY+7OUSxoE7cjlPI TqUtmMh4rEy2ZBus4Mn4WnmRoWr+bHxwol8UCx+O6hCxTN8RFp4l2DRIJIDTJ6EyvAAT 17X6lQFAuEKJxTYqB7H9s6HjCrlGtIetRYU88OstbIXxhg+KNfffadCxPXsJwNp5D6jy IqFA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61si17988729plr.51.2019.05.13.12.28.40; Mon, 13 May 2019 12:28:56 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730708AbfEMQlf (ORCPT + 99 others); Mon, 13 May 2019 12:41:35 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:33994 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730487AbfEMQlf (ORCPT ); Mon, 13 May 2019 12:41:35 -0400 Received: by mail-ot1-f67.google.com with SMTP id l17so12413726otq.1 for ; Mon, 13 May 2019 09:41:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DTPzcVxKVm0Pc29DEn3cmhWP30Ec3xr80gOHbyh3pg4=; b=QG2mbnD/pg43/wvci35BUJXBplXdFtkPUwxgiVtSRrOnbrAghEdN11U7jyH4HAtaLq as/HKfkfkW/OagvryKGt/y8q90bU16aIJEzewQTwc10EWpOS8RDIG8p5XtWkltdzj/lk DzlQL7ItOxwJOUZXAJSEyPxRKhP5m017gan6js+29Gpqubyu6q0xVB38fsatwrY537Yl ELL0wvgiN0/3UfL6E6sEhrYK3Z4Bpprfue2R/eYBt+c0V/2o+iwJrnJC3hR+8xqPK9ZP EkKB4X3aVHAniXwPmXbb1rRUhrnxfrS6b2aG58mpVydwHp3N//lHavbIMXP1U4dYZLjR JRpQ== X-Gm-Message-State: APjAAAVX7OKfCfHRdC1TUkIBjMsoh+9xXFssLeOwAyenlYnfvCVXKZME Qd7Jlb5eZEIzvYTGmrtbI9ea4JjNK2c3SoHJfuJW4w== X-Received: by 2002:a9d:4808:: with SMTP id c8mr2886658otf.316.1557765694735; Mon, 13 May 2019 09:41:34 -0700 (PDT) MIME-Version: 1.0 References: <20190513033213.2468-1-tobin@kernel.org> <20190513071405.GF2868@kroah.com> <20190513103936.GA15053@eros.localdomain> In-Reply-To: <20190513103936.GA15053@eros.localdomain> From: Andreas Gruenbacher Date: Mon, 13 May 2019 18:41:23 +0200 Message-ID: Subject: Re: [PATCH] gfs2: Fix error path kobject memory leak To: "Tobin C. Harding" Cc: Greg Kroah-Hartman , "Tobin C. Harding" , Bob Peterson , "Rafael J. Wysocki" , cluster-devel , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 13 May 2019 at 12:40, Tobin C. Harding wrote: > > On Mon, May 13, 2019 at 09:14:05AM +0200, Greg Kroah-Hartman wrote: > > 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. > > Thanks, I should have gotten a compiler warning for that. I was feeling > so confident with my builds this morning ... pays not to get too cocky > I suppose. > > > With that: > > > > Reviewed-by: Greg Kroah-Hartman > > Thanks, will re-spin. Don't bother, I'll fix that up. Thanks, Andreas