From patchwork Fri Sep 11 12:46:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264036 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 024A5C43461 for ; Fri, 11 Sep 2020 17:30:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B57992220F for ; Fri, 11 Sep 2020 17:30:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599845444; bh=uwKdI65cJkdS+Q/qobIiqnPK8gOXzU532WtF7jDAj6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=EYWNfMqQ86wefzAJiIJGWT90Ndoj0TfqgeJCHa8tmdNQazS6PcR6Mk8/hPMLjZJDV Y4Jvw+J5i+SELNj5+8/xBZ79GtJ1rNTiPCnAj9OLx8w6xfiY2mkRQ1qD+HT3jWoIlm 379LsPRQ5P1hoNeCxjjh1OMV/WOHauPoU4009jws= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726093AbgIKRal (ORCPT ); Fri, 11 Sep 2020 13:30:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:48796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbgIKMze (ORCPT ); Fri, 11 Sep 2020 08:55:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 5FC2522208; Fri, 11 Sep 2020 12:54:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828882; bh=uwKdI65cJkdS+Q/qobIiqnPK8gOXzU532WtF7jDAj6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bLh6lwFjkHr8yhMvhYrdP8P+MEjTEk9KZje1+OVezhHU0F2yk4nkfufrVUgHrRZVA efTzCHozyGpL3IMhYbuboJrDKND8wRo9K7pAyjP5elNllnxfCbyHpPSw0WSxsH5yPA V0tVCeDe4wMcdtMWfD4CJBC1E3brn2V/sP1gn7UE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ye Bin , Mike Snitzer Subject: [PATCH 4.4 43/62] dm cache metadata: Avoid returning cmd->bm wild pointer on error Date: Fri, 11 Sep 2020 14:46:26 +0200 Message-Id: <20200911122504.542882684@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Ye Bin commit d16ff19e69ab57e08bf908faaacbceaf660249de upstream. Maybe __create_persistent_data_objects() caller will use PTR_ERR as a pointer, it will lead to some strange things. Signed-off-by: Ye Bin Cc: stable@vger.kernel.org Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-cache-metadata.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/md/dm-cache-metadata.c +++ b/drivers/md/dm-cache-metadata.c @@ -501,12 +501,16 @@ static int __create_persistent_data_obje CACHE_MAX_CONCURRENT_LOCKS); if (IS_ERR(cmd->bm)) { DMERR("could not create block manager"); - return PTR_ERR(cmd->bm); + r = PTR_ERR(cmd->bm); + cmd->bm = NULL; + return r; } r = __open_or_format_metadata(cmd, may_format_device); - if (r) + if (r) { dm_block_manager_destroy(cmd->bm); + cmd->bm = NULL; + } return r; }