Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp209573imw; Fri, 15 Jul 2022 01:19:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sN/+CZv+lcv8ItlIk20UDB5BC6wNF+T0SvlEbwfmGxEsRGipsyw+euH88jIMJReJv+RrlN X-Received: by 2002:a17:907:72cf:b0:72b:9943:4caf with SMTP id du15-20020a17090772cf00b0072b99434cafmr12221150ejc.370.1657873179780; Fri, 15 Jul 2022 01:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657873179; cv=none; d=google.com; s=arc-20160816; b=bewwRELBZahD0CeV2YWmb+2/Ye24DuX93G3gqN3fnZ28FqF6A8oc+OUZDnrkGxQesD XuUnv02O2c7CW8hCcGtKSWeYKREnYGvflEePLX1DUaTR0X3AFHyu2v9uxNmMZYRze6oI xq7PohNXilZq2SOM7Z06eDGVgsspaGK2VjgaP25nYKGgX6vNYFQ7tJB0bB9LXtWzuG7J XpW06lXMOnEHxgY2dudc7l8Cy10Tu4fsJgxscI3UZmGEFpM2JDYskFG0Sib2xndK4h9h NNuK0v8GrQWrt+EC/YGpNw0/jVJHg6ag0BJr8jxODVcTc5kJdKxyuLv3VXE4RJa+d1U/ OiSA== 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=cwrZmNCSRjuzMIQT+tURFfwkYdiptMDdrXd4mko6Rok=; b=jG89aMmOQsODY/sOsTS1zfdrAj7ytLdvNDdC7bSfOjqpud9aAzt8X4UoSDz88Bcmr4 1FSBG9wiESN6rf+OEnANgO43kei8KCC17+WodmJDaqWjEbS29RRyH0vEYVTsBfsmJqTp yg2RCPes2wAzf9asbtZxNfw6itkjDvvlXQIbR7MJ+BZ1b2qLSuCi6p6FSyA/vqOLIdE3 dBoivsCCZJP6dNkudeZMKY52wo4OIdklCLNyftCNw8N3LuspliFE53IYr5IACJfFIfS7 jHgCKjxQ2X5G1Ccts1jDyGOE2d9YFIPAe6n2WBUYDik0U07R5DbjgYPwG/mpnqnne8f0 D7oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b="octZNLD/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qm7-20020a170907674700b0072b7fa15683si4265172ejc.312.2022.07.15.01.19.05; Fri, 15 Jul 2022 01:19:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@163.com header.s=s110527 header.b="octZNLD/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232547AbiGOHyg (ORCPT + 99 others); Fri, 15 Jul 2022 03:54:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232471AbiGOHyf (ORCPT ); Fri, 15 Jul 2022 03:54:35 -0400 Received: from mail-m973.mail.163.com (mail-m973.mail.163.com [123.126.97.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 37AE67D790; Fri, 15 Jul 2022 00:54:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=cwrZm NCSRjuzMIQT+tURFfwkYdiptMDdrXd4mko6Rok=; b=octZNLD/Y5JcfldsSN7+r bB85h1HyoFhWu5Z5oVLR/al1WrplJuDFxNxvpZQ3/GczPt5QYiHwsQc4UM60gdtC bgyk3Ib25/VbJ+QcR6q3PGITEDbHf6Tv61nWDV2lCU/Kt1J5Sc86ie0Xaj2q/N8V 3wqN79/iKNKV84Wzc5IyaE= Received: from localhost.localdomain (unknown [123.58.221.99]) by smtp3 (Coremail) with SMTP id G9xpCgAn2x4JHdFiDeT0PA--.706S2; Fri, 15 Jul 2022 15:53:48 +0800 (CST) From: williamsukatube@163.com To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: William Dean , Hacash Robot Subject: [PATCH] fuse: Fix a potential memory leak for kstrdup() Date: Fri, 15 Jul 2022 15:53:43 +0800 Message-Id: <20220715075343.2730026-1-williamsukatube@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: G9xpCgAn2x4JHdFiDeT0PA--.706S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrKry7ZrWDCFy5Kr48JFWDArb_yoWDGwb_Cr 4fGF18uFs0vrW8Xw4DCws5tFyIgw1rGrn3Wr4xKFnxJrWjyF4avr9avr95ur4Sgr48WFZ8 Grn8JFyfAw42qjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU5Wc_DUUUUU== X-Originating-IP: [123.58.221.99] X-CM-SenderInfo: xzlozx5dpv3yxdwxuvi6rwjhhfrp/xtbBSQw-g1aEEKSO1wAAsG X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org From: William Dean kfree() is missing on an error path to free the memory allocated by kstrdup(): sb->s_subtype = kstrdup(parent_sb->s_subtype, GFP_KERNEL); So it is better to free it via kfree(sb->s_subtype). Fixes: 1866d779d5d2a ("fuse: Allow fuse_fill_super_common() for submounts") Reported-by: Hacash Robot Signed-off-by: William Dean --- fs/fuse/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 8c0665c5dff8..2d10afad07f8 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1449,8 +1449,10 @@ static int fuse_fill_super_submount(struct super_block *sb, get_fuse_inode(root)->nlookup--; sb->s_d_op = &fuse_dentry_operations; sb->s_root = d_make_root(root); - if (!sb->s_root) + if (!sb->s_root) { + kfree(sb->s_subtype); return -ENOMEM; + } return 0; } -- 2.25.1