From patchwork Thu Sep 16 15:56:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 513773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B652C433EF for ; Thu, 16 Sep 2021 17:14:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 875CD60F23 for ; Thu, 16 Sep 2021 17:14:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242937AbhIPRPy (ORCPT ); Thu, 16 Sep 2021 13:15:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:37128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240991AbhIPRHT (ORCPT ); Thu, 16 Sep 2021 13:07:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6C56161B2E; Thu, 16 Sep 2021 16:36:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810164; bh=UGHrKtu/1BmUM34YT/nG1a3LYXSd907BIv+JWrNiEwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Np0UaftB4KEtDs8oh1IRnVgjIX12sNlQA8gpgelxdZgSi/sAh2GQ2ciM9ZWNx9/SZ p6n0CNVwuaXujdlbByuKpvRZQukGFCRd5OzBoEjSugoZn2Wz7oRXoLZkQUTQdJPSuG m8aiipzD74a7kKLWqX/dSPbTe02LNMWU6QhXV1Js= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Ilya Dryomov Subject: [PATCH 5.14 023/432] ceph: fix dereference of null pointer cf Date: Thu, 16 Sep 2021 17:56:12 +0200 Message-Id: <20210916155811.609654755@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Colin Ian King commit 05a444d3f90a3c3e6362e88a1bf13e1a60f8cace upstream. Currently in the case where kmem_cache_alloc fails the null pointer cf is dereferenced when assigning cf->is_capsnap = false. Fix this by adding a null pointer check and return path. Cc: stable@vger.kernel.org Addresses-Coverity: ("Dereference null return") Fixes: b2f9fa1f3bd8 ("ceph: correctly handle releasing an embedded cap flush") Signed-off-by: Colin Ian King Reviewed-by: Ilya Dryomov Signed-off-by: Ilya Dryomov Signed-off-by: Greg Kroah-Hartman --- fs/ceph/caps.c | 3 +++ 1 file changed, 3 insertions(+) --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -1746,6 +1746,9 @@ struct ceph_cap_flush *ceph_alloc_cap_fl struct ceph_cap_flush *cf; cf = kmem_cache_alloc(ceph_cap_flush_cachep, GFP_KERNEL); + if (!cf) + return NULL; + cf->is_capsnap = false; return cf; }