Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp4950602rwb; Wed, 17 Aug 2022 08:33:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Mco0g4FFMbXX3wSeAP6Fi47xCZjS/KGp6DiBfQ79pqfnFPV85HU24KXhLb/l2RDmYvPDp X-Received: by 2002:a63:fc4e:0:b0:429:9ab8:c315 with SMTP id r14-20020a63fc4e000000b004299ab8c315mr7947797pgk.26.1660750391072; Wed, 17 Aug 2022 08:33:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660750391; cv=none; d=google.com; s=arc-20160816; b=fEPVTzbWlX48h/TphH8p+m1nvlb3Tjuxu/C0wq0hyGtnX0Timuk3+N5GglZUtI6bHH qK6P5jqO4rNqs/VIne7VlCtGUISdgBQx9ASiuwqYlddXuUMFf9R+XBhO8PgV+DD6trmd G7bjQCcJlrWNImrb/tXxuG6fIJ8sqPSABSutktMAdIQzl1+ZFacSQuoRy+X8/rzprenP BlyUOFZGgCAGOfH8+jESBTFgSeYDytaGCGZfSEq9NEqBvsPzYC5n6k2EeBu7McmA8oxZ LB87fL0lcD9qe997X3nbJfT+5h+HW+YsNiyeI74ANOdFWDzYHgS+7etQwqhD2r2umzCb u0sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:mail-followup-to:reply-to:message-id :subject:cc:to:from:date:dkim-signature:dkim-signature; bh=15A3o8pzw2uvkF+OZu80gJIKsHpWU2h8OmqN7hLoi9c=; b=u0VMCigVr4pBiWuvAWKj52+u5nOuGg4l1nM3MM1K3i55EnkoHkSK/cc4wpL77KkMch mjrnzvljcbhUzydNWyaiHxk+qARZhp131S0FBnyNgvyURAlQ32rasfGCHk6BAP6bYF09 eDLrO3G2VoxRVrs3Iq/RfP9VOlfDty4dr8LtZkd5V4chHPHVDkRx1A4RdNFQSealY0Qt mnrORgcR4wCdGA4eWA44cLvPruq4lx6pAEEVFWfqk3/KpC9dnUhfzRlnlzFS6tnSLHM9 L1ToT3+3YJej1Q7gFIUM4V6c8+955ejzwWa9yd0qrO5/FTJGPGImorcN7Jq/7Yx1ahmi w+kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=byZ5M6Ok; dkim=neutral (no key) header.i=@suse.cz; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 12-20020a63124c000000b0041bc0b2cf86si17375821pgs.446.2022.08.17.08.32.59; Wed, 17 Aug 2022 08:33:11 -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=@suse.cz header.s=susede2_rsa header.b=byZ5M6Ok; dkim=neutral (no key) header.i=@suse.cz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240102AbiHQOsO (ORCPT + 99 others); Wed, 17 Aug 2022 10:48:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237192AbiHQOsM (ORCPT ); Wed, 17 Aug 2022 10:48:12 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08D9FB49; Wed, 17 Aug 2022 07:48:09 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 7CA8D1F8E7; Wed, 17 Aug 2022 14:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1660747687; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=15A3o8pzw2uvkF+OZu80gJIKsHpWU2h8OmqN7hLoi9c=; b=byZ5M6OkqndNJf5cravAAyIk73wnU1evVNDbRHdMR6hAkH2WSadTfZ/Szc9uThaVMfzxso QLTLf0YuXJuEtp9RBseB3lcML773Q4ZDEHixMxVMHw+K00fHwvx0qlQnzlACpovkXfKelK QpC8pKChdEn2Ic80Adbo7jsTQpq8Q+o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1660747687; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=15A3o8pzw2uvkF+OZu80gJIKsHpWU2h8OmqN7hLoi9c=; b=ftmddMI9wXtkN8ie6tQbGQp9dnaD607NHOnj9dTSTyTuou+4snPz1AgVhJNpgbFpZUXtQ2 kpX7Z/2yg4Q5jfBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3BB2E13428; Wed, 17 Aug 2022 14:48:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id HRqJDaf//GKIfQAAMHmgww (envelope-from ); Wed, 17 Aug 2022 14:48:07 +0000 Date: Wed, 17 Aug 2022 16:42:56 +0200 From: David Sterba To: Zixuan Fu Cc: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, baijiaju1990@gmail.com, TOTE Robot Subject: Re: [PATCH] fs: btrfs: fix possible memory leaks in btrfs_get_dev_args_from_path() Message-ID: <20220817144256.GE13489@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Zixuan Fu , clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, baijiaju1990@gmail.com, TOTE Robot References: <20220815151606.3479183-1-r33s3n6@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220815151606.3479183-1-r33s3n6@gmail.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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 On Mon, Aug 15, 2022 at 11:16:06PM +0800, Zixuan Fu wrote: > In btrfs_get_dev_args_from_path(), btrfs_get_bdev_and_sb() can fail if the > path is invalid. In this case, btrfs_get_dev_args_from_path() returns > directly without freeing args->uuid and args->fsid allocated before, which > causes memory leaks. > > To fix these possible leaks, when btrfs_get_bdev_and_sb() fails, > btrfs_put_dev_args_from_path() is called to clean up the memory. > > Fixes: faa775c41d655 ("btrfs: add a btrfs_get_dev_args_from_path helper") > Reported-by: TOTE Robot > Signed-off-by: Zixuan Fu Added to misc-next, thanks.