Received: by 2002:aa6:da0e:0:b029:115:a171:fe4c with SMTP id z14csp1262454lkb; Wed, 7 Jul 2021 02:52:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxufLVw6vVX8/EbJTbs0cKj9T+VzrizSTvaitcqMeNKRe86M2O5K7NZ4uwrM6slyK2IrDt0 X-Received: by 2002:a17:907:8693:: with SMTP id qa19mr22986841ejc.189.1625651529504; Wed, 07 Jul 2021 02:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625651529; cv=none; d=google.com; s=arc-20160816; b=keRHAgdnDVipwFT4+QvpS8oILnAz8PQoTv4blfjy8dDh4kdS1iw1PHNJucKG3CE0t7 2QmrBdB0GWzytAb8lUOXO+A2q3EHcyQwtetgdZeQKr3QjQcU93lrS7N/tg7D68aQC0dG Bv+/e03PxboNZePr4ktOMsmiDM6v8CfJwNQTRXsiD4VYTaYK5Rk5cQWwu0GapJM6Da+W 2GMSGSQ5K0CbvcpbphPMyzlamcp03yY7l1nJ++FMJZlggB38YnBnFTsjr2H6Q8uZUv2/ FITav7JALTSOtnTHSeagdnn1/CRJYjwnTH5xUq8MwVSEfMV3QNB2obpRbldwDyW58lxN NKmw== 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=tg8Rx1wWlkNbqejilODw641z/b4x4fF9Uuzm0P4x4D0=; b=uQ5iyqRV7KkMUhaZ1r5DsLBqYwe66rD55ufA+t6lkvuSMZxb4CWfkNeP5o187ChS3o SOHqW4YlFpvYC9D/rV20IkWqBZc5ZAKa0gEquMQ5UEF7CiVsmvvW1jsU2DoPfuWJbdc6 ouCdpP10wOFbMvF6MagWkVP1Cg3fVhR+p7qjvRQcXHwH/tJfsc+AMxeahAUWNXgcdG77 FZzDIH7E4nXhtvM/mt1iQaFWepDMCBdBaRiP8joSibKAipLJt2EzP73L8hzbXB2rnW4S 9BxhRlpYdQeUgehX+EYJ5MIg6M46nzQYhk/0z3X/2U/lmO2MqFVqywaALXVl2GuPLXKn 3f1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PrljIE+w; 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 dn2si12614878ejc.136.2021.07.07.02.51.46; Wed, 07 Jul 2021 02:52: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=PrljIE+w; 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 S231404AbhGGJvU (ORCPT + 99 others); Wed, 7 Jul 2021 05:51:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231315AbhGGJvT (ORCPT ); Wed, 7 Jul 2021 05:51:19 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11E51C061574; Wed, 7 Jul 2021 02:48:39 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id b12so1615311pfv.6; Wed, 07 Jul 2021 02:48:39 -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=tg8Rx1wWlkNbqejilODw641z/b4x4fF9Uuzm0P4x4D0=; b=PrljIE+wuY2ULWNMaoB/MgNZV+baMZEw5jLy1StHdilD/VcS99UswWyI5DXhaoGnEc AK4A0yeTJpj7bkQC1MWz2HCkCqXW1ZHPIioYLmu5prnU1wrqtg1CmDK6aMjhYzlbVL67 3nB+owYsvkETSfWHkXSrJ7bqkCO33K5pLz9eXGDh29BvuaxxTeFylm8m5T5rtWVI4nkz garM9kmXjh8FTwyk0Tki6hAMb7fxkX0Lw3Au7we3s03pmxuFOiDkBBW9JXCS+pOvJ0BS Ebu3SgcWHAGkBwNkJJOWZyc3jOVTJgaV3Y1UBdKg8y/KvqWA54wIP4HqHEtMrqcrLw9v kivQ== 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=tg8Rx1wWlkNbqejilODw641z/b4x4fF9Uuzm0P4x4D0=; b=r6xGre6ap+T7NQ3a6eWv9vXHiynFrC4x2/eIl5MERb5DJIwJW7lNQgIBI9Ll8DaKGO Z2xobVGNNl/65Ouk0/qsDrjtwclmCYdh1cRd+fk5AUvGZNCEhXef6SGHZtjeB6BUd5tV fIE4zDGqhZmnHf9LdDbw3h866ybKrhOf8J+zww9lzCrNoxwNgPfu/qX4M+aG7oPouEvh fEoItdcdQ0A8x8noYyZK9igPw4ss90c75KnXqQfOYKE1ljj3vznaU6wu6BSO8vUw+6DL Uc2W15+E6yOhYGZMBVuYJQGZR5NaORSteN0tU2B38BaRZ3mL64FRxwCb2OSFu1O5T9Ix kj5w== X-Gm-Message-State: AOAM532qJQufzXPrpitT2qnzgJSLqT9ZriLGCXwnzEn0VLbh6f3kQWTw Mc+A4QqbxRmtdr0udFDpG5E= X-Received: by 2002:a63:5b02:: with SMTP id p2mr25412371pgb.161.1625651318569; Wed, 07 Jul 2021 02:48:38 -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.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jul 2021 02:48:37 -0700 (PDT) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs , LKML Subject: [PATCH 3/6] nilfs2: fix memory leak in nilfs_sysfs_create_##name##_group Date: Wed, 7 Jul 2021 18:48:23 +0900 Message-Id: <1625651306-10829-4-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 return 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-4-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 43f660beb9b4..5dc468ff5903 100644 --- a/fs/nilfs2/sysfs.c +++ b/fs/nilfs2/sysfs.c @@ -92,8 +92,8 @@ err = kobject_init_and_add(kobj, &nilfs_##name##_ktype, parent, \ #name); \ if (err) \ - return err; \ - return 0; \ + kobject_put(kobj); \ + return err; \ } \ static void nilfs_sysfs_delete_##name##_group(struct the_nilfs *nilfs) \ { \ -- 1.8.3.1