Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1270317pxa; Thu, 20 Aug 2020 07:12:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq98zz4YJveQS0SD36NNFVpPvLVx4jYgx15+Wb7VLW0bB/PROTM3VieiIZy1oznRfxLYdE X-Received: by 2002:a17:906:bb0e:: with SMTP id jz14mr3602717ejb.525.1597932723908; Thu, 20 Aug 2020 07:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597932723; cv=none; d=google.com; s=arc-20160816; b=HpyBEeEKdqeV0cE1nTpU6MPUSEKbu+l3Fx6KoXN4d0BvxnZ2Hm0eTOBKwta5NH9zN/ sp42fXUoLf4zJJO+HzvYjOSF5TGl6yhw8DQN98rblI0qLAscwxp9fjwyHY+clsvINM17 zKt0/iLSf6wIbBR+PkR5u+moH76eX8iDKFFa5ZuOThNbFjvQrLLepJK3wlWrguuggS40 AcI9rMflM9qbt9UVgFgh/K9Cbze2dAJM0CS0RapIi72POK7X7c5v0xgQEa89RGbdvFRq h59T8BWYLDR4b+aDH5dzYgAi3y/iWV0f+zBRJ+1+H8e73JZHXH1k1nGeFqPdq4hkpcCg ix2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5r2+bcTkw7h0OrzbimjsbnIsD6K+ih/xGsEWYKszbN8=; b=nRA9vQoI7+EsXShNpPYFoaEboIdEf+sXQ4WQoflLpxHZwop+GWOTJBnUxO4d21Q6s/ wKFR7KczeGE8OdUasTY0YIU/GEMKT9vCxHKLaXh2KGSPpP8VDdlQMOxutfo0OsYNABWO MMWmHxdrN1yprNtIBOtyiOU1fKEPWa0zNpnTwZbFNWrT+UgupXRMc67ZR5jzcXFH10ps I0z2YBKn1X5/FvlqjfPz27hW5BwS57ZX0+srCzUiEWhmyttWhT+EXZaJTw2Wbflh0Oqt mjzikbYg1KY2gCPi+XxvHWZ4klFEk7d9dX0f0PzejgE3wL+ZlrLLjPjN6JZPQwdvFh3N iSww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GxMBba+i; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id le18si1108078ejb.705.2020.08.20.07.11.39; Thu, 20 Aug 2020 07:12:03 -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=@kernel.org header.s=default header.b=GxMBba+i; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731112AbgHTN5t (ORCPT + 99 others); Thu, 20 Aug 2020 09:57:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:33620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727093AbgHTJZP (ORCPT ); Thu, 20 Aug 2020 05:25:15 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 53D3022CB2; Thu, 20 Aug 2020 09:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915514; bh=6TE7FFTve3v8uF7YgQQfnuQC/0K3ZNMVPhrYhtJvlkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GxMBba+irKEAzfm67wa0hjX6luxwCRIyKREZ4cRkTYDpTTrsL6JVPi0NDGJ3XSRaO jOgaU3lMCYubC8IhnMb7agmFQ3iR8NAVTP2VMtPisssjJsaae6CV0t9LhC9T+lbUnc 1X1anDG6Kdr0f+VyRaspaGIOzfvqtRrEJltzwhSU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , Qu Wenruo , Boleyn Su , David Sterba Subject: [PATCH 5.8 041/232] btrfs: check correct variable after allocation in btrfs_backref_iter_alloc Date: Thu, 20 Aug 2020 11:18:12 +0200 Message-Id: <20200820091614.771086747@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Boleyn Su commit c15c2ec07a26b251040943a1a9f90d3037f041e5 upstream. The `if (!ret)` check will always be false and it may result in ret->path being dereferenced while it is a NULL pointer. Fixes: a37f232b7b65 ("btrfs: backref: introduce the skeleton of btrfs_backref_iter") CC: stable@vger.kernel.org # 5.8+ Reviewed-by: Nikolay Borisov Reviewed-by: Qu Wenruo Signed-off-by: Boleyn Su Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/backref.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -2303,7 +2303,7 @@ struct btrfs_backref_iter *btrfs_backref return NULL; ret->path = btrfs_alloc_path(); - if (!ret) { + if (!ret->path) { kfree(ret); return NULL; }