Received: by 2002:aa6:da0e:0:b029:115:a171:fe4c with SMTP id z14csp1261410lkb; Wed, 7 Jul 2021 02:50:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJDa+S7HZn41EQg9y4+e/j4yfoTsAQdhKJ+qKJer5NKituWo8WJSzEzEMkt2KhkNzLeB3l X-Received: by 2002:aa7:c68d:: with SMTP id n13mr28859108edq.33.1625651418482; Wed, 07 Jul 2021 02:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625651418; cv=none; d=google.com; s=arc-20160816; b=j2XjxpUTxd0N/POwslpmO8147t3Oryeygp3HVZbTgF09JFIvNRfXsgJuTv6gNumIbn EekkqkR2ViAflPXaLXqVZD36+IQ4cYwWRjni0fSE20jRAy6BxZ4xbaokFSd/VXNziPGg OGMQ3xcyHBQUJFvnM2OdMDyEBCPMd+TDdN5IVorF3EsjOXsoPqEKGYZkQjmY1xTzLtcJ VkHgdW54dOhae6wsWgKUvQ1Rs0xMLzafpje3KfyBZ4zS3vGD1cUQOlX8jfwslq11mUM6 C6iySW11m9rZxsaN4K2UhGsURLGugShpZkKaZnw95l9kjaAM8Dv+XDfX2dF6G+hX+YxD FjPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=g65fz9nM8vuwTrmBSnevy9pcjESld9hrzhcHi3C3t4A=; b=NAGM+ouvHi6dzAFnomiOP5IAuq1iN7l9/TnHi+pGdayBfE5s9A9W/9DbGsuTVSb6+y 5nerHCoT1S9AQxZuZcX+KWpU2kqg36racMETrHKIhcEY1IGAGSRZe/b0U79/ghXjVONK 86BZz3aan6l5TjBDZSs+5RBJ/C4Rnwik4clVmtq4xUbOHmQrP0inMQLZ/jhIQyFLzJVX jTxg6YIoGx4wysCiiuPtLXOh+UmSZ00jvxmS3+16yWlA7aZJh/9eCI8DwJkt7M5eT+1b iv38gkNr5ikz2alfVjVa6u3UQ1HdNXa4J4QZVMtb/RW28xrpL/VdMdhFKBRlyIFtAk9x vgVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ikrRirSr; 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 jz26si16974211ejc.747.2021.07.07.02.49.55; Wed, 07 Jul 2021 02:50:18 -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=ikrRirSr; 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 S231449AbhGGJvZ (ORCPT + 99 others); Wed, 7 Jul 2021 05:51:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231437AbhGGJvY (ORCPT ); Wed, 7 Jul 2021 05:51:24 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7DF4C061762; Wed, 7 Jul 2021 02:48:43 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id a127so1604634pfa.10; Wed, 07 Jul 2021 02:48:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=g65fz9nM8vuwTrmBSnevy9pcjESld9hrzhcHi3C3t4A=; b=ikrRirSr4cUmzEpdQmmFKc3izLb2YT7TEKkwWpA/6cJD74N7eMpo5j3U53PUJo1R0q CRonVthx/k2QMQG8mWc0UBQ2khL/d6GA+IxHqHfVXC/7+lSE0YM+TrqdilRXESMVh1ZH pqzRavBwP/YobXByESncEa1Y6EeZaf01367AMDI1gh2p3pEiGiL9/sfnOWcW3Qklw3Ba qXQwifUzvGFIDdCbZ/VZN9LJ0X7TlF3Wf/cLY08XOESlyb9Ck3IaDUG9edOp1NEieHwJ NFqzqa49e/h9nXKcaQC0MG42XoFkJlq5HjRmSxBgzBa0KtCVS34V2VAoi1T0FmBedHV+ wFhg== 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:in-reply-to :references; bh=g65fz9nM8vuwTrmBSnevy9pcjESld9hrzhcHi3C3t4A=; b=Q+nqScUHtflFAT4xHvI50OXx2th1sJhIOVfdYSCeiPFTHG9qj5mLpdRQjqHA2hvf/c zu5jqJUtkRNeMRzboP7MITuQImo1FBklfq1dgdQ+Ox9uWoBfqB937UW/Og4aMEOI3NNg n/0QO0uiJBfm3Lujjb8Qs0Mbluo6xgCHf+CV6ZvxmRmymFMwTHKFUM1sHPtUcQE+7+1Z M8lQCQPnx0RzIo0ousflYqZ267Y1qkRhu7gJKbvHA9TkkMP+AIblbW6EL4zfwJrnzQAi pz/mkD9VVSYZue+I4M6lxzho10+m7DB99GvTKOONZJVkUpxsbwkTfNmaU6Y5QnYlbfvV x4KA== X-Gm-Message-State: AOAM532iBChIuG1zjrFyE/7QWIGXg485UlTcQjc2EZtPjEq5XKQIGQdS Ns2MfNKSjnibLIcct7F3ACA= X-Received: by 2002:aa7:9216:0:b029:2e5:6989:4f1a with SMTP id 22-20020aa792160000b02902e569894f1amr24373120pfo.50.1625651323405; Wed, 07 Jul 2021 02:48:43 -0700 (PDT) Received: from carrot.localdomain (i60-35-90-140.s42.a014.ap.plala.or.jp. [60.35.90.140]) by smtp.gmail.com with ESMTPSA id gd19sm80137pjb.38.2021.07.07.02.48.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jul 2021 02:48:42 -0700 (PDT) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs , LKML Subject: [PATCH 5/6] nilfs2: fix memory leak in nilfs_sysfs_create_snapshot_group Date: Wed, 7 Jul 2021 18:48:25 +0900 Message-Id: <1625651306-10829-6-git-send-email-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625651306-10829-1-git-send-email-konishi.ryusuke@gmail.com> References: <1625651306-10829-1-git-send-email-konishi.ryusuke@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nanyong Sun If kobject_init_and_add returns with error, kobject_put() is needed here to avoid memory leak, because kobject_init_and_add may return error without freeing the memory associated with the kobject it allocated. Link: https://lkml.kernel.org/r/20210629022556.3985106-6-sunnanyong@huawei.com Signed-off-by: Nanyong Sun Signed-off-by: Ryusuke Konishi --- fs/nilfs2/sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c index 34893a57a7b9..44b9ad70a564 100644 --- a/fs/nilfs2/sysfs.c +++ b/fs/nilfs2/sysfs.c @@ -208,9 +208,9 @@ int nilfs_sysfs_create_snapshot_group(struct nilfs_root *root) } if (err) - return err; + kobject_put(&root->snapshot_kobj); - return 0; + return err; } void nilfs_sysfs_delete_snapshot_group(struct nilfs_root *root) -- 1.8.3.1