Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1100196ybm; Wed, 27 May 2020 16:27:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZPBMQMxHQV+T+ExWdVggr/fduHKoRpjLMSflrTMqDuIJbK/mM1yZYKOhuFjGBmP5Il1cI X-Received: by 2002:a17:906:838a:: with SMTP id p10mr585255ejx.243.1590622029361; Wed, 27 May 2020 16:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590622029; cv=none; d=google.com; s=arc-20160816; b=ew+/hJfSw7114EEAOylwcSDn1PaeIl1jEqBwdagP2TvqwlAmuP9jZ25zcj3DiJaN0i 1KKsFosd4nJ6noOL9m3DIqQfX0eItuyPdcuR2A/x//dfGWKbF3xudwwikJyfCcFCNoLY DEIC0QImui5frhkvWPwjZ1K6Xhh5lCuN0k4K6rKYX7Mu4jrY/42zvzQg4lC5r08NMQL1 GWjtg0fAtMkaLLVeq+wFcNOewjg10WI0lOF8sfOYrUTPLzC3MjtzrzkbxrzO6d1ypNPY PpA81jA+tdRNXmkzNTTupTWnXFf66OXjpn7d6kfinnHBMdUzFEpBeu33QKCJ3eM0Os+0 +tCw== 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:dkim-signature; bh=wIVZxySUnBYIOh1u+axvWyg8nrJdsmWrI8rTFK6qLVg=; b=o/eTfm/GXVXCcxPeOwqn26nIFIGIILz8aj5E7lHPzXUfP+a+BFDZcNpXB+4Dyl0bVV zhIjGYRULTumN4IpwNoLN63Ic517v2KZzKJ5BApCSxdF642EbJPGdcbE2DY2rhqfaLeG 7vpkNoS3nQ33RVR0t/V2gx+GvQnZ1ADIgEBIbdwcj8B5t+SRbn8TQccOLyG/wTONP74a ajbGKk3rKwQecXH1PZqX5GOLZ3drp448evXG+8E/IWw47OxEZZipauWjQeGWaxkfbn+F CX1sCf8DbvL9fo7kwne3itCGN4s7oMLdEVhNKbysza6EFSzi4krkiLj5jxsibZgUQoeu n4lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Qg5jBIOJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si2705684ejh.152.2020.05.27.16.26.46; Wed, 27 May 2020 16:27:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Qg5jBIOJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725850AbgE0XXt (ORCPT + 99 others); Wed, 27 May 2020 19:23:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725819AbgE0XXt (ORCPT ); Wed, 27 May 2020 19:23:49 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1C1CC08C5C1; Wed, 27 May 2020 16:23:47 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id q13so2458842edi.3; Wed, 27 May 2020 16:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wIVZxySUnBYIOh1u+axvWyg8nrJdsmWrI8rTFK6qLVg=; b=Qg5jBIOJ/fnN/Gke/Ow3JmBDV/gHExZTNzXoLEYshE5IPCFeaIyXdpSeewVt/pCERE QSy8ZFFHWMzfJ5mcOTathiF9yOLEHFX+Ib3VyDj3WORcpvTCUJ3SpvdVk5TU7NAcnsoW iDeHRty7UUBWQ78SUsxkvxadSzDLJX4ctgRVCjTbMh774Go9YfE5GtXADJsj3c+kUHSz L0uV0TAG0qejh3Hzz/Q8c8WW5K1Crr2ZcFSC30XUE01UzgI85Tb1VGKKmSokO5k2QDGR euSSu74G2kCqAykqTJv0cEAd5cAuVHbMbJP2Cfo/G8WVzhHSPKgypqe7I4jgJULBgUOg uOrw== 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=wIVZxySUnBYIOh1u+axvWyg8nrJdsmWrI8rTFK6qLVg=; b=qonFjQ6x2wRzpmdRCE0Z1AazjDR6rXgHSzq7EFnZ9HEmThHwU2/WVO+jfjYvjuJxQP lFLcFSTFj6zXdOzF9IMh/LQitpE/FfV9ZuoHR9nq+mjOkhsR9Ph77VajrvADHjU+dc5V ca5jRAvxavGw9S/eJ+czQ8Yk2az9UKvpJZEBw4mu8SvvygDoCd3sEURrlTEJNRsTY4xM IgYlgmMlp9L8SpheiEl7qVczv3rK7KN7Jf/34dlSOrYR75O5dpLeqw/0gA1gEe4+Jt1g NqqD2cqLVtoKRSECo4XEzJtiRJjkCZqP2IKRuP3JQj/1AsGS0SnbfJcWLDztkyM9iWds NqIQ== X-Gm-Message-State: AOAM532zoTE0svSJMfD23KpF7Vb0HNWAmLgWZAuvo2g2AaLHENoCythq 6/luA4gaJpSh2vRGTEsz3vXxw7HQ6N/BOZuIsBs= X-Received: by 2002:a50:b082:: with SMTP id j2mr450297edd.201.1590621826391; Wed, 27 May 2020 16:23:46 -0700 (PDT) MIME-Version: 1.0 References: <20200527230442.24228-1-wu000273@umn.edu> In-Reply-To: <20200527230442.24228-1-wu000273@umn.edu> From: Ryusuke Konishi Date: Thu, 28 May 2020 08:23:34 +0900 Message-ID: Subject: Re: [PATCH V2] nilfs2: Fix reference count leak in nilfs_sysfs_create_device_group To: Andrew Morton Cc: linux-nilfs , LKML , kjlu@umn.edu, Vyacheslav Dubeyko , wu000273@umn.edu 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 Hi Andrew, Please pick this up as well. Acked-by: Ryusuke Konishi On Thu, May 28, 2020 at 8:04 AM wrote: > > From: Qiushi Wu > > kobject_init_and_add() takes reference even when it fails. > In nilfs_sysfs_create_device_group(), the memory allocated by > kobject_init_and_add() is not freed when kobject_init_and_add() > fails. Fix this issue by calling kobject_put() to clean up the > kobject. > > Fixes: da7141fb78db ("nilfs2: add /sys/fs/nilfs2/ group") > Signed-off-by: Qiushi Wu > --- > V2: using kobject_put() to handle kobject_init_and_add() instead of > kobject_del(). > > fs/nilfs2/sysfs.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c > index e60be7bb55b0..8416f915d118 100644 > --- a/fs/nilfs2/sysfs.c > +++ b/fs/nilfs2/sysfs.c > @@ -999,8 +999,10 @@ int nilfs_sysfs_create_device_group(struct super_block *sb) > init_completion(&nilfs->ns_dev_kobj_unregister); > err = kobject_init_and_add(&nilfs->ns_dev_kobj, &nilfs_dev_ktype, NULL, > "%s", sb->s_id); > - if (err) > + if (err) { > + kobject_put(&nilfs->ns_dev_kobj); > goto free_dev_subgroups; > + } > > err = nilfs_sysfs_create_mounted_snapshots_group(nilfs); > if (err) > -- > 2.17.1 >