Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35742613rwd; Mon, 10 Jul 2023 11:53:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlEKDHHJqZ8sjBbuA5lzqGmuMJqkO4iMT+VsfqD/c8DpKueMQUfMACZQa9KbRRaK8Azi65dc X-Received: by 2002:a05:6402:60a:b0:51e:5322:a642 with SMTP id n10-20020a056402060a00b0051e5322a642mr6493856edv.27.1689015189368; Mon, 10 Jul 2023 11:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689015189; cv=none; d=google.com; s=arc-20160816; b=xBBCj5BC8kWOPdofG22oL0d9MYw6xSEIy/+Tps4aBFHWLAZUgp3yKou6TfPw8Uovep aR4iuFrn5NLqjaFoPV1qxAFrej7EBO4gWfNiU+KAkFL4//XgTcnbRsqRnnBUtefn27II go/ckk2EKAmgWzUEFMnAHWjGlkMi4POGwYT5PNfG6S5jQVs0RB28rxJlNHW2OrGS9YiQ B27CygNkbbcUgxPGQoVz2vAnqd51SG/bFLGjcOqEKq7VAaomz9KvWrCa5Sur7lkwo8zS LunLiFsQoa3T1pW3n3Ccz+xzzCnKVvuLWZoRpFa7oux7DtXku9RhXDSbhWTX9Y7BiCfQ /jMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=hX43wX5YZh6iHzSCX1+t92V+mCCfDYrt7xXXyg9RNFQ=; fh=oTbztAqscQQW05WkZvVn4GRIYmTKTLJlTxzJcHtkWvE=; b=mcenKpgyfGHonrDHR0MOWwEpepd962AsnkH+J+GN0GqlktkXMGiUFR8QWwT1P2WMVU SxAO1nidI0FJ4ig/fAURqnXZukSjpDTZ+uPjMYcVw7sJREBX6n3epcShFRaWfOFnxLY8 /IBd9FSkh9nxZGEeQeeOUG+aLDVs4ADYcxULQtm19tzf+nb7+7/y1vCJzUCOSzA8nqqn SFeinfRo0TA7V776eMYy0RIn8P0C2cNezuM7iXMzashNJ0r5jpxOXRLvNVg7emP6KvOs UTpbj4Fh0xy/31J5e3rDfpN9CP+Q+Zh6/Aou2kZgAo0O7vpgexmDU9NX4+mh0kkXOCwu 9EQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sman5wYf; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y17-20020aa7c251000000b0051e2ded9b50si100132edo.632.2023.07.10.11.52.38; Mon, 10 Jul 2023 11:53:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sman5wYf; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229964AbjGJSmr (ORCPT + 99 others); Mon, 10 Jul 2023 14:42:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229528AbjGJSmq (ORCPT ); Mon, 10 Jul 2023 14:42:46 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9A6AB7 for ; Mon, 10 Jul 2023 11:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689014522; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=hX43wX5YZh6iHzSCX1+t92V+mCCfDYrt7xXXyg9RNFQ=; b=Sman5wYf1vlZ8k/ulgjDGgME8WIh31luWVr8XaflfNHywM8v+vBUJgxopWkt1WTEpNaIrC /S5wv7aBoV/ScukNs5Yij/NIgWMMAtvyfnrSHhbCnm9wxeU4RHHNAceogZ4qa+H/Pva7GP 4mPMA+WoWd3q1obGHiBMHnp7g3pw4nQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-472-R_an3UnWPY--gblrUcNqcg-1; Mon, 10 Jul 2023 14:41:59 -0400 X-MC-Unique: R_an3UnWPY--gblrUcNqcg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26C263C34662; Mon, 10 Jul 2023 18:41:59 +0000 (UTC) Received: from bcodding.csb.redhat.com (unknown [10.22.50.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA183C09A09; Mon, 10 Jul 2023 18:41:58 +0000 (UTC) From: Benjamin Coddington To: trond.myklebust@hammerspace.com, anna@kernel.org Cc: aahringo@redhat.com, linux-nfs@vger.kernel.org Subject: [PATCH] NFS: Fix sysfs server name memory leak Date: Mon, 10 Jul 2023 14:41:58 -0400 Message-Id: <6702796fee0365bf399800326bbe6c88e5f73f68.1689014440.git.bcodding@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Free the formatted server index string after it has been duplicated by kobject_rename(). Fixes: 1c7251187dc0 ("NFS: add superblock sysfs entries") Reported-by: Alexander Aring Signed-off-by: Benjamin Coddington --- fs/nfs/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c index acda8f033d30..bf378ecd5d9f 100644 --- a/fs/nfs/sysfs.c +++ b/fs/nfs/sysfs.c @@ -345,8 +345,10 @@ void nfs_sysfs_move_sb_to_server(struct nfs_server *server) int ret = -ENOMEM; s = kasprintf(GFP_KERNEL, "server-%d", server->s_sysfs_id); - if (s) + if (s) { ret = kobject_rename(&server->kobj, s); + kfree(s); + } if (ret < 0) pr_warn("NFS: rename sysfs %s failed (%d)\n", server->kobj.name, ret); -- 2.40.1