Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp256816lqn; Thu, 11 Apr 2024 23:37:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWrZoTkgKsCyOTpCq9BQEBKGFDipQMnrP6e3INGYmRQCzEvzF58jtrGWum5qv4gNTyFJ0ExIqeNN5LBh6Q6OmGWqf20tCNHGW1vpW67nQ== X-Google-Smtp-Source: AGHT+IHpvdfJ2u2s9ryjwQ1rp0x6mJ5ujQVPerHxnPfFvvQTIXB8PYFHYwW22DwZ4lwY65hwaKxm X-Received: by 2002:a50:a6c4:0:b0:56e:2a0a:c131 with SMTP id f4-20020a50a6c4000000b0056e2a0ac131mr1291282edc.17.1712903826853; Thu, 11 Apr 2024 23:37:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712903826; cv=pass; d=google.com; s=arc-20160816; b=o40tUWJh5F3xe1RPnVZkuGUS5/Nxsk1kCsNWrQPFGVHlXbcyGnZtrWge5xBzRxihPj ZPsu8aSj4QSlHt1dLJ9y5tVe21JX6BDD6gVxKlafOHCfvGBpmj596gz3ADah/Hc5BqZd /N8pK1j1uDjjTZzmbYyaHjWsn4UKKQfewJKsHwGIWdfyfyZCEMlR6zk8ZIvCzPxcf7V8 Xj8hvu8bgNUnLyFrrOE+CxeRqe3sZJhczsuXGeEn9cM7t58zh+o4PM9nUA/+EsdWDNgU aPRk8NL3dxDYEYAKh/MjemZNv+Ja5JzXtR+oSE6hSs4b1RRLScUiX3m0h3FU1BrBWw/j 47Rg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=ka7eaEbhlydQjdeelMX6+WMiSQfMdktoE2KFreIs8Ds=; fh=w5TM/CE3VFVqg0wbgPG390uTnUHuZFFyMgnfHFx1y2I=; b=jty7mod0DtTrnVolqkIJ+uSGKhhI//+ShQafPRuLK5uWnIJG6XQZpeprh/VD/a8wBg jG69jWUkTdN4gA1MntNp+2w9m3r6S7HzVo7ElqLSyP/weWZCbcyV6esjm7w+lRecSt+s JhYa8/PpR2xi7nc3us+pyN9S0TMLQOe8Px7I3L1YfveZs4NYJsHkbhYdjj/6mYsK1apT LAVhkQAhbCb+00qPLiQgyp6uzNCa3ShzpDm6GaZI2Fs5noUlkSEWpFBpaRUMozQtYFPW Fh25TbFfMLZFvIuzVZQsY//kve3LpD61eQdMNo2HVVfeDoa268sF3bq4aaCDe30IHaES E9Og==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hxBIUjjb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-142046-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142046-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x60-20020a50bac2000000b0056e4b7bdb7asi1408889ede.527.2024.04.11.23.37.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 23:37:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142046-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hxBIUjjb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-142046-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142046-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5943D1F25030 for ; Fri, 12 Apr 2024 06:37:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A50C94087B; Fri, 12 Apr 2024 06:36:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hxBIUjjb" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDB0A1BDCF; Fri, 12 Apr 2024 06:36:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712903815; cv=none; b=pdZVRwlb+ugr6qaogZIEsSf2/lHvxlq5QDuq/VUaMcVr6fSCXT1yFStU9rYsZfXE+1z7bVoYwlzN8LJRHBUiuYGRg6k4WoL/I7lhkNopK8/xp/ZtslMGC7HjwVcEGtUIbDrjpDdDIHKLdanPFoyY40d2VD54nLqT5SrloLbD/Ic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712903815; c=relaxed/simple; bh=NkGJwr7h3mbH6nk/AhjlXuCyRNAnQFgNgi7XccAHJjA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=W0z+74nIwY9+32XxcxIhgrxOc9OhQKIr71zyM5rQrZsvW43uxf84wT1T5yAriPf6/7d3nzNmaqBlnTI++oJiS+0Yl41w6OBpf8gvos9WRIzRTVYLmR6DOiok1sqs+m83g1YSACR2+8Ny9p2paLUJfnaJB8WQddqPbZD2+fnhL1k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hxBIUjjb; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC0FBC2BBFC; Fri, 12 Apr 2024 06:36:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712903815; bh=NkGJwr7h3mbH6nk/AhjlXuCyRNAnQFgNgi7XccAHJjA=; h=From:To:Cc:Subject:Date:From; b=hxBIUjjb3ul6O2R4GKwr3ab8w8qRzQXgp8kN9VwSnAgHX1JE8FIR9sr9ZO7P/chvY cxAE614O32F4PonDUsO82x2sg4y25HdC0/QAhagqcqBY+zsVnswUfDfyUT/6wiBCuy nXNR08z+sh1yCbiyYaUVyZJWA/TR7msaz0UVgMDz6Vjgjc1Mk5jLLLgm6tAaMHbGB5 Q4K5iyAd5mw789J9vg6x6k29L/SF80CiSxL6tFgUwucxdOkYINrEuPAxL2irMbmYc0 n0UDx0y0PwtikbPbe6hJ17T/+mxZK7P+TRIJE2GAoTu6d365IllHJ1h7N/ocfXwx5r xlhXDGlIrQhMw== From: Chao Yu To: Kent Overstreet , Brian Foster Cc: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH v2] bcachefs: fix error path of __bch2_read_super() Date: Fri, 12 Apr 2024 14:36:38 +0800 Message-Id: <20240412063638.2068524-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In __bch2_read_super(), if kstrdup() fails, it needs to release memory in sb->holder, fix to call bch2_free_super() in the error path. Signed-off-by: Chao Yu --- v2: - add error message in error path pointed out by Hongbo Li. fs/bcachefs/super-io.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index ad28e370b640..cc80d7d30b8c 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -698,8 +698,11 @@ static int __bch2_read_super(const char *path, struct bch_opts *opts, return -ENOMEM; sb->sb_name = kstrdup(path, GFP_KERNEL); - if (!sb->sb_name) - return -ENOMEM; + if (!sb->sb_name) { + ret = -ENOMEM; + prt_printf(&err, "error allocating memory for sb_name"); + goto err; + } #ifndef __KERNEL__ if (opt_get(*opts, direct_io) == false) -- 2.40.1