Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1311272pxb; Fri, 10 Sep 2021 03:06:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzphNNXyCcWPM6eEo6efoIH4WYHbRetvIotkyfKja4bTNNiMDTjp+3RGVqsXFq+hv2wr73H X-Received: by 2002:a05:6402:10d6:: with SMTP id p22mr8063627edu.168.1631268375655; Fri, 10 Sep 2021 03:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631268375; cv=none; d=google.com; s=arc-20160816; b=HkdsCoFFEKNBcNa548o5kBwGLpfMeLvwdVELZT+26Ehs2g/7l3aL/PORgQ9PkRBg4K G73difdGLreRKmbH3u65KcxDBrIXsFK5x8AOvhq/joFIrC2Oa1sB2/7Q7njjkZ6J/txJ 5Es6HtxmWFWPAcelMin6SDzbW0jnW4lRa0rALd25uGm6jP5DPwU9OfxH/XloRpv+iWVJ itnKj82/Trhb3G7OXfuUTXJ3XyKSE737ZL6NC2TRxX29daydtMCQNxFPlKKjo5PqwquD xSUv3SDwDuvstBoJqJDnYYo3E9ozeSNc1Xqd+5Vyn+CDSf2jqBXgGUxPjt0M9OAaYFxc FWnQ== 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=CLu82bq5SWKeIc/2RlhTe1WwLhYQwCATV9tHg0yoIUI=; b=VeqFIjKzwPKn7PrpDiqvGEZwnCDFgHLUiELVMSx13KuagXKLXL7HrSExEOTj9ewYq9 /NxUnaW7VYwl/3oHztAh2Z6dW4kYUBujmCPAUwlohExhpi4rJO+B/KQXKWa2zICtzxFO 25PtTmuhSyaF+n4azjq7p5a/ypQt7CFTuwbZXB9Cydvo6egA8a14XyR8SwWmSYmZ4EZ/ ZTZpfXXcCfmcDS45jZ2cxw7xdPqHE3pbE2DTf9ojAp9mGzYEFH6CuCeQ43M+1Gr40Bp1 yI79XU5V31I5slA2gqgHhvLQhW01jLxCqATIfyoWH2O+dZGh2qgdxOikXCOtkGV3gcTz rc+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=KxW7shY4; 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=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gv43si4326484ejc.88.2021.09.10.03.05.50; Fri, 10 Sep 2021 03:06:15 -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=@canonical.com header.s=20210705 header.b=KxW7shY4; 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=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232129AbhIJKDQ (ORCPT + 99 others); Fri, 10 Sep 2021 06:03:16 -0400 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]:32836 "EHLO smtp-relay-canonical-1.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232187AbhIJKDP (ORCPT ); Fri, 10 Sep 2021 06:03:15 -0400 Received: from localhost (1.general.cking.uk.vpn [10.172.193.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 45B7C4017D; Fri, 10 Sep 2021 10:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1631268123; bh=CLu82bq5SWKeIc/2RlhTe1WwLhYQwCATV9tHg0yoIUI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=KxW7shY4l4HMrOtyTk0llxEcnqsRn06pUSZaWASEYRNefbBxdxa3rBqXzBGxUjDbd uydUBiT0wBgCS7HKjQTLqdugvQfs5Wmuk1+HahX8hkIBk53OAB0GFPauaDbzkwjf72 P3NMxt7/bzehSSZzsNPngLQTfWYkVSVPVyXBqWQj8wI+5u0odltlBWxlxBUfg+PB8V jtfpKsflJb9ZKaJbIQju2OQsFvs5VWx80tUPSNyufZO4PDIayGVgRvsZy3tZ87WzoH 1ls0189rswfKoHZNe+55aQdqBK4j089rl4/DiSXiysxNJX5L0l1HqPxEEBIuNnhFz8 fcoqhv/wcqd+Q== From: Colin King To: Konstantin Komarov , ntfs3@lists.linux.dev Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] fs/ntfs3: Fix a memory leak on object opts Date: Fri, 10 Sep 2021 11:02:02 +0100 Message-Id: <20210910100202.29254-1-colin.king@canonical.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King Currently a failed allocation on sbi->upcase will cause an exit via the label free_sbi causing a memory leak on object opts. Fix this by re-ordering the exit paths free_opts and free_sbi so that kfree's occur in the reverse allocation order. Addresses-Coverity: ("Resource leak") Fixes: 27fac77707a1 ("fs/ntfs3: Init spi more in init_fs_context than fill_super") Signed-off-by: Colin Ian King --- fs/ntfs3/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 3cba0b5e7ac7..69f23db0d727 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -1450,10 +1450,10 @@ static int ntfs_init_fs_context(struct fs_context *fc) fc->ops = &ntfs_context_ops; return 0; -free_opts: - kfree(opts); free_sbi: kfree(sbi); +free_opts: + kfree(opts); return -ENOMEM; } -- 2.32.0