From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 767342343C6; Thu, 12 Dec 2024 16:32:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734021131; cv=none; b=ObOJf0rVruOyUvU3oaGZB8s1KmtU94KFCrqkgRghy3510F4uBsykaTksTOWeIOxXb9kzZ2J7tZZ7KKlJMqLYK0DzcWp8qoNUpo0aiBSaEKw4MM+oEumrRUZYMvT+M+frPBxeXzbasqpVgSc+ly+cMDqU91uhHVQhlnU+eMhlG/I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734021131; c=relaxed/simple; bh=YVfpKO3oQPupK8J9Anq/1QOBamsKsc7nUkfX7ql94PU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PMaAz2Bvf0vruUxUus+m0C3xWXGylBuFFVnI75dwIE5w1QqWByendA4YuFDpL0eVf5jE+mAgabvChpNbk/IDd7hSCjEPjVSuue45y9yMkpfqi4otwlbolIB/4fqj++S/m/zPGCXzN2ZGWsXaVhGq8zwtq0vseTvKJbRSNAD3w4w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KFHMKQy9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="KFHMKQy9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E9B5C4CECE; Thu, 12 Dec 2024 16:32:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734021131; bh=YVfpKO3oQPupK8J9Anq/1QOBamsKsc7nUkfX7ql94PU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KFHMKQy9fE3NnmMpkLgis8dKy/vRfOUMgJLXM5JRkMZMp8lQ2yaB7HYFiSCsRRVc6 Hw4a0Ado+piY9GJ4u384EhbEGpyTnX2Y38jPH3+1+EKMr8UtuhKp1Lld9WiJ4NdQb6 NexeKQzvHV6QuELwk7H3I0G9OxRY/Jak7siV7FNQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Liequan Che , Zheng Wang , Mingzhe Zou , Coly Li , Jens Axboe Subject: [PATCH 6.1 624/772] bcache: revert replacing IS_ERR_OR_NULL with IS_ERR again Date: Thu, 12 Dec 2024 15:59:29 +0100 Message-ID: <20241212144415.715648406@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241212144349.797589255@linuxfoundation.org> References: <20241212144349.797589255@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Liequan Che commit b2e382ae12a63560fca35050498e19e760adf8c0 upstream. Commit 028ddcac477b ("bcache: Remove unnecessary NULL point check in node allocations") leads a NULL pointer deference in cache_set_flush(). 1721 if (!IS_ERR_OR_NULL(c->root)) 1722 list_add(&c->root->list, &c->btree_cache); >>From the above code in cache_set_flush(), if previous registration code fails before allocating c->root, it is possible c->root is NULL as what it is initialized. __bch_btree_node_alloc() never returns NULL but c->root is possible to be NULL at above line 1721. This patch replaces IS_ERR() by IS_ERR_OR_NULL() to fix this. Fixes: 028ddcac477b ("bcache: Remove unnecessary NULL point check in node allocations") Signed-off-by: Liequan Che Cc: stable@vger.kernel.org Cc: Zheng Wang Reviewed-by: Mingzhe Zou Signed-off-by: Coly Li Link: https://lore.kernel.org/r/20241202115638.28957-1-colyli@suse.de Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/md/bcache/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1726,7 +1726,7 @@ static void cache_set_flush(struct closu if (!IS_ERR_OR_NULL(c->gc_thread)) kthread_stop(c->gc_thread); - if (!IS_ERR(c->root)) + if (!IS_ERR_OR_NULL(c->root)) list_add(&c->root->list, &c->btree_cache); /*