Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 354E03559CD for ; Thu, 22 Jan 2026 01:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769046168; cv=none; b=cgCcD63gFXQrwALA8KHzaGFJBMIXGzwsX1uEZwIFbHPc2zOFtsjgfLGvNlIFoh8LjRMubNqlvXSPg7Pp5RgwQdSjHMQKtbD4vY/1eB+1tUrAXDhCqMoi+vqZv9aG6aYouqkcvKoUQWS05mxlw3F8UQvTwh5qECD8mh/lkiNK3NE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769046168; c=relaxed/simple; bh=pajYxcyeoD6+0DWcFdiuSEesPUlQyfohckrVNbO0fU8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Lug6eHqTSzKGcT2VcRrcKZ3R7N3dGJAuwhGqd42ayI6Y1bBWt60gODSVWyzHMilT5zIPPGoMltGLRDbFcrH46/MrQD2UM0LkSovqr0UjamB/FLOYBjF2DAk1BjIV/33JdYv9ybERt7rcoCcABh3dVl+LCLDzPx8bxZD+YabuQVQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=PD9sM5Cj; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=L745B1wO; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=PD9sM5Cj; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=L745B1wO; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="PD9sM5Cj"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="L745B1wO"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="PD9sM5Cj"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="L745B1wO" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 0BEA45BCC3; Thu, 22 Jan 2026 01:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1769046162; 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=SwOSowd91xoTuvXjWZ28drp6BIP8b3vYYoTOjHWJ3j0=; b=PD9sM5CjqjCu+j65SNtbLngDC7kPHT35snpTL/cNrpjGZG8hZBrZeK4aPlDEPpP5n7v1/0 nZE1Tr9FPGWIqz+/qRvXqC5zOY9pQYs1DchSR/WtfuGuiJQjJlixj1OTiY0jXwTDdKfHQ3 s+ADC1VZT+D2SZjezJmuf69zqAQ2H2U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1769046162; 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=SwOSowd91xoTuvXjWZ28drp6BIP8b3vYYoTOjHWJ3j0=; b=L745B1wOUXaU4uv1bVw3Nu0HGxEZNYalpZEW+7sSiI8FBb52MnZe53+Us0JvFdaT4mt80k u7zOKg94lEgEIGDA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1769046162; 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=SwOSowd91xoTuvXjWZ28drp6BIP8b3vYYoTOjHWJ3j0=; b=PD9sM5CjqjCu+j65SNtbLngDC7kPHT35snpTL/cNrpjGZG8hZBrZeK4aPlDEPpP5n7v1/0 nZE1Tr9FPGWIqz+/qRvXqC5zOY9pQYs1DchSR/WtfuGuiJQjJlixj1OTiY0jXwTDdKfHQ3 s+ADC1VZT+D2SZjezJmuf69zqAQ2H2U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1769046162; 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=SwOSowd91xoTuvXjWZ28drp6BIP8b3vYYoTOjHWJ3j0=; b=L745B1wOUXaU4uv1bVw3Nu0HGxEZNYalpZEW+7sSiI8FBb52MnZe53+Us0JvFdaT4mt80k u7zOKg94lEgEIGDA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id EBF3C3EA63; Thu, 22 Jan 2026 01:42:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id g81tOZGAcWkjbwAAD6G6ig (envelope-from ); Thu, 22 Jan 2026 01:42:41 +0000 Date: Thu, 22 Jan 2026 02:42:32 +0100 From: David Sterba To: fdmanana@kernel.org Cc: linux-btrfs@vger.kernel.org Subject: Re: [PATCH 2/2] btrfs: deal with missing root in sample_block_group_extent_item() Message-ID: <20260122014232.GT26902@twin.jikos.cz> Reply-To: dsterba@suse.cz References: <30034e48a39502638fbac40662914132895cca4b.1769028677.git.fdmanana@suse.com> Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <30034e48a39502638fbac40662914132895cca4b.1769028677.git.fdmanana@suse.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) X-Spam-Score: -4.00 X-Spamd-Result: default: False [-4.00 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; HAS_REPLYTO(0.30)[dsterba@suse.cz]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:replyto]; REPLYTO_ADDR_EQ_FROM(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; REPLYTO_DOM_NEQ_TO_DOM(0.00)[] X-Spam-Level: X-Spam-Flag: NO On Wed, Jan 21, 2026 at 08:52:38PM +0000, fdmanana@kernel.org wrote: > From: Filipe Manana > > In case the does not exists, which is unexpected, btrfs_extent_root() > returns NULL, but we ignore that and so if it happens we can trigger > a NULL pointer dereference later. So verify if we found the root and > log an error message in case it's missing. > > Signed-off-by: Filipe Manana > --- > fs/btrfs/block-group.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c > index 6387e11f8f8e..b3345792f3a1 100644 > --- a/fs/btrfs/block-group.c > +++ b/fs/btrfs/block-group.c > @@ -607,6 +607,12 @@ static int sample_block_group_extent_item(struct btrfs_caching_control *caching_ > lockdep_assert_held_read(&fs_info->commit_root_sem); > > extent_root = btrfs_extent_root(fs_info, block_group->start); > + if (unlikely(!extent_root)) { > + btrfs_err(fs_info, > + "Could not find extent root for block group at offset %llu\n", This is probably a message copied from elsewhere, we do't capitalize the first letter and the trailing "\n" is provided by btrfs_err() > + block_group->start); > + return -EUCLEAN; > + } > > search_offset = index * div_u64(block_group->length, max_index); > search_key.objectid = block_group->start + search_offset; > -- > 2.47.2 >