Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1781061ybh; Tue, 14 Jul 2020 07:13:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykKzVdjsGpUMAWajbfrveInJGTYM8NYfuLQWHvF0sfGypR9xklJKk6UoHiD80Vb5xN41/L X-Received: by 2002:a17:906:19c9:: with SMTP id h9mr4507401ejd.526.1594736019280; Tue, 14 Jul 2020 07:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594736019; cv=none; d=google.com; s=arc-20160816; b=0DV/SUZq3fZ8OfM7OltFK4Knv3Owqne/YdOlxfgUXuMwrDdtIfRDFmoejJlfsjNhqM R/w6dvAcPJ5jiGmgQHkVIvpWPK4pxsC05ojOmDM88kddjTR1tIWty0MumArVq84V033R sAqaXj1rDLDKfdrbZkzKzeKJkxXI9GD+xxdW6ZvT5Oi+nDKDgJvvKBzYneINxzxgOnm/ FRQFpnrymdIDehkjqqmyAWDYBKVrvQb+4fV9mPbfDR4rQPqNUjBXAGOpDaVzBq17+bln D4yEb81q3PE8W+Ps+R9Zw2Reu6vVpL6mhAXAsPq281HA4YGvMYHbXFw0+cltWDzFTiEq X6fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :reply-to:message-id:subject:cc:to:from:date; bh=xRHcMTU/3JB6bIww4tbcaU2sNNFAXxhqJqI+Sc6SEnY=; b=xFZWYtV/WE77xBdhZobBj3njuv8FFJE0AvIKT1b6T0IZk8Rp6IRwJ3WEgVvITnspvC gIZUvYjxurAJhaDqeHiOs/O9I/37QICsHBpQo4auc1Pf10QK0S1/cJO89mNjiGMH9tRo ht84ocDfKFGQpx32+sbopbUGmoQRQhgOzKhRcTtaEKWdpIAyEVDZm+Z7bE/8I8/Mk8Az rPm4IXR878idgqb7YqKCXEscMN/1SDbC+QeEhky/X25RrTpf/o3guFN2svrSnKxPIIXf B81+iGmoU9+Ss9uQR5KDoG/rT/SaGc8YYlN8BqZg9CfxXlZJIayVNS27z2pUy8E+RUcG Wjzw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x29si11809801edi.61.2020.07.14.07.13.16; Tue, 14 Jul 2020 07:13:39 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727831AbgGNOKm (ORCPT + 99 others); Tue, 14 Jul 2020 10:10:42 -0400 Received: from mx2.suse.de ([195.135.220.15]:57518 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbgGNOKm (ORCPT ); Tue, 14 Jul 2020 10:10:42 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E7E22B04F; Tue, 14 Jul 2020 14:10:42 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 2B1DADA790; Tue, 14 Jul 2020 16:10:18 +0200 (CEST) Date: Tue, 14 Jul 2020 16:10:17 +0200 From: David Sterba To: trix@redhat.com Cc: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] btrfs : fix memory leak in add_block_entry Message-ID: <20200714141017.GQ3703@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, trix@redhat.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200707132908.10987-1-trix@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200707132908.10987-1-trix@redhat.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 07, 2020 at 06:29:08AM -0700, trix@redhat.com wrote: > From: Tom Rix > > clang static analysis flags this error > > fs/btrfs/ref-verify.c:290:3: warning: Potential leak of memory pointed to by 're' [unix.Malloc] > kfree(be); > ^~~~~ > The problem is in this block of code > > if (root_objectid) { > struct root_entry *exist_re; > > exist_re = insert_root_entry(&exist->roots, re); > if (exist_re) > kfree(re); > } > > There is no 'else' block freeing when root_objectid == 0 > > So add an 'else' > > Fixes: fd708b81d972 ("Btrfs: add a extent ref verify tool") > > Signed-off-by: Tom Rix Added to misc-next, thanks.