Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1089419ybm; Wed, 27 May 2020 16:07:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwloz/u6sP83c5eV8RN/hhOgItOTIHS2Swv2pRmMfCxJbbPunM3YWErP0M/NGMRl2JNKK/z X-Received: by 2002:a05:6402:1c1e:: with SMTP id ck30mr422590edb.154.1590620879117; Wed, 27 May 2020 16:07:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590620879; cv=none; d=google.com; s=arc-20160816; b=gZNzXo3gfMEHFE7PwAY7hatmHNUz8+YXAdimgWlPGWF3NA+VkSh2jGSRNl1Ges1c29 qPfIz3Voqq3HtSHsKJXZ1+SRd9V0TxbWlSEIET9V4t57X1yfO3ofsn5NZqp5hlYDVQxm mWM06L26bnL2IicFV1TKtk1OPl316Tsjipf8zZoQKWNTSBL7Bq6P/4W/vyRs7o8hLbzV DzK/OABAsd3TNwr73XWIEBUtldkxaZVdnfxH3styfo5zKbqVW+cAnSDA0vWA/OMzrOlk PQ06HUuoMwJX8ngSMLDfCq5zHMdM7R7S5Cqku5l3XLX0YFTtlbjp3PXptum11YEyeUWE 9p2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:dmarc-filter; bh=YHV5y6pIipCjzQp8LJwYmqlUFnQseQ80Ln/ckTdkCZw=; b=knr2sD2sEEC80reBjzbTU+tosnGWJ8JkJdodo1bGT+yeJBcjWCnutz2+HLAEcuI4N+ xFJWtHNC3uqDtN6MJgKtE40TNNl8L3QyvxgmXCQ7yMgrW8J3QjbyLTDO7ywui313YdSG lhjClGqr/jmCgjus9GcnVSwsBss676hz9p52EWyo1ZKLj7gh81ucWblc/wGguNax+zGB YXFu+uctboj5QsTWflQigVUzX83EbUtYKUOGbfe+ZPTnnrQZu6v3OrHmpJW9eVT9qDGI 8bnMgxsfwkDAhrtB61YrOGXfJGGQDD/QPIP8zOe87YopOCNq3Wcu3Mo7qHrdx7VlVF/I gxzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=google header.b=cTHdopN1; 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=QUARANTINE sp=NONE dis=NONE) header.from=umn.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ba17si2492177edb.20.2020.05.27.16.07.31; Wed, 27 May 2020 16:07:59 -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=@umn.edu header.s=google header.b=cTHdopN1; 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=QUARANTINE sp=NONE dis=NONE) header.from=umn.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725900AbgE0XEv (ORCPT + 99 others); Wed, 27 May 2020 19:04:51 -0400 Received: from mta-p6.oit.umn.edu ([134.84.196.206]:46850 "EHLO mta-p6.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725795AbgE0XEv (ORCPT ); Wed, 27 May 2020 19:04:51 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p6.oit.umn.edu (Postfix) with ESMTP id 49XRHQ2DVQz9vBsK for ; Wed, 27 May 2020 23:04:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p6.oit.umn.edu ([127.0.0.1]) by localhost (mta-p6.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hMizPfaTZ9ye for ; Wed, 27 May 2020 18:04:50 -0500 (CDT) Received: from mail-il1-f197.google.com (mail-il1-f197.google.com [209.85.166.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p6.oit.umn.edu (Postfix) with ESMTPS id 49XRHQ0YfKz9vBrh for ; Wed, 27 May 2020 18:04:50 -0500 (CDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mta-p6.oit.umn.edu 49XRHQ0YfKz9vBrh DKIM-Filter: OpenDKIM Filter v2.11.0 mta-p6.oit.umn.edu 49XRHQ0YfKz9vBrh Received: by mail-il1-f197.google.com with SMTP id v87so21591587ill.23 for ; Wed, 27 May 2020 16:04:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=YHV5y6pIipCjzQp8LJwYmqlUFnQseQ80Ln/ckTdkCZw=; b=cTHdopN1hULb06TaGd+P4W4iF4wc7U/uaQW2V250xUb74vT/pfcAPR/g7vHCexSE9Y 2W4eeIUZWE0ubJXJebuMkJuDiQDogzRy969KUhph1Z8Fpyxp7S2HZ98bY6d0mWzii+ol JP1eqF6PGJdyzbh5D74xjdDym8bsW0Yd3N3ZLKoWZYAiwW0FAHmg3AzvKgh/Ip/VmI8J J95FoovDFBV1D2IOtBvw8iabv3ImXcgts0MdLraATS6I5cLk6NCJTGSPmnKuf/p7xdsb S218PRxjeZqROisKi/g/v3FZpOnnkqlTG9Z+Tv6PsXxvGLt6vUmKFf+gQMR2dNTH8MwG QpNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YHV5y6pIipCjzQp8LJwYmqlUFnQseQ80Ln/ckTdkCZw=; b=CViW1HfhGZPzqLUcFf7dF8P58aG0k3wk9CTDo96JTLTRRhdGu2QH/Se817PThUTqBQ fOxC44omiNztF2us+9Dsz83FcBcE2wL09fs+5fnSD64HK7L24dIom/QhhrQnF8Wt/qYb /FsEUQWotdiXo8hWDDOayxJrvnz2Awqwj25GqAjzstUF4t30mQqFb7ZCYdxP6IHC5QGm QvBpoOVNEHq9WnZ80Hng/K77KOmS6tgNo9uQPMBwXwfrGRBPVwg7MOiF0iKkCUCfVFNZ PgbcdFhOxBttI8InyLp+jTlyRcLhxN9Tvxwb4bKkk36RjHLZAHXpSGVsI3zuKRcQkrKM AKrg== X-Gm-Message-State: AOAM530qOb5n6zAH4zo+Eoez9HZeq004lAtnPZp5XZcQgLMk0fYe3UR2 odvWvcLu/9XWW528CXQKGEl6Uf5BgRXUIu9SkjyU9noiKN2e7fuGnJYhteiT4mVjHcz0gclejtS 2nC/T4IGOxQoOB2l3+Vapn5je31PD X-Received: by 2002:a92:b111:: with SMTP id t17mr546476ilh.241.1590620689540; Wed, 27 May 2020 16:04:49 -0700 (PDT) X-Received: by 2002:a92:b111:: with SMTP id t17mr546454ilh.241.1590620689242; Wed, 27 May 2020 16:04:49 -0700 (PDT) Received: from qiushi.dtc.umn.edu (cs-kh5248-02-umh.cs.umn.edu. [128.101.106.4]) by smtp.gmail.com with ESMTPSA id s2sm2215847ilj.29.2020.05.27.16.04.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 16:04:48 -0700 (PDT) From: wu000273@umn.edu To: konishi.ryusuke@gmail.com Cc: linux-nilfs@vger.kernel.org, linux-kernel@vger.kernel.org, kjlu@umn.edu, wu000273@umn.edu Subject: [PATCH V2] nilfs2: Fix reference count leak in nilfs_sysfs_create_device_group Date: Wed, 27 May 2020 18:04:42 -0500 Message-Id: <20200527230442.24228-1-wu000273@umn.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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