Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4158902pxk; Tue, 8 Sep 2020 12:10:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbm/tZ2CmFRPrPO1putVfRa4ANr7Xo7IbFew2JmVJdGiHyD1gmh1KyQfd5WhwHTMNxtmEI X-Received: by 2002:a17:906:328d:: with SMTP id 13mr28432072ejw.71.1599592253851; Tue, 08 Sep 2020 12:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599592253; cv=none; d=google.com; s=arc-20160816; b=uluS/zBEnR4SIIIWr167n+iABM7LAWaiux68qQyMIHC+zFOFkr6rYDd1tcnEijLRf3 4WKjFyJ8Ut3eXW1TP9cccPXny8unGlbU486/uVO5V2tnJGJ7AMgwMbQTqcNqTzYo7+yh TpWHXM3JWtugxXY4XvLWwH6RBvoxoS1LfDM2NQ4Zc3maSRAN7zH89apM9DieOsLlxsUP AUCyhUiczBUpINIYq5LBxrmbc0ShNBac8ncs7hfm26fs473EWU1ioaGDutXPHyFh525P OJhVyP1w+a7GUn0xE6Ow7Htof2GRfHsX4ULU5efdo1TdUEli0rFL4axW6MONrZFj4+aP 0jJA== 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=CT4vgZwSGwXqAa7HUzkSLA5lhdsG7kvB7s5e0ESgDvk=; b=a60lI3f/2ABjciwFVHkcLA8y3qFiCzzr8TTc8ACuzyGtqQsH1CohJ9OWZWSuIzzLj4 12hl9sHd+eIBXolDPA5RLwCxfu1PZzmxfXhV4ALHbWrwbooyr4TYboRFe/QgvccJ0opt 9WNyFHAlZ1B3dinV7kc1CrXY0a+rji1W5TWxlanf3z16yxNX7me0qm1jOECbCv7ytlDB T7oT6TpvG4I1dGZwOxi+EB3xfME/3dhfiLVHnV8LuN1dLdyI3FktX7IsPdy81a/AtakT HYKErfd8/RfWoblQKx83OuP7vH6LzFpI8zqe/f2GQQuWX1YpPPGt3/pRsNByAy5ACqr8 Uwhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NKwclUCe; 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 p11si12104397eji.157.2020.09.08.12.10.31; Tue, 08 Sep 2020 12:10:53 -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=NKwclUCe; 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 S1731639AbgIHTJC (ORCPT + 99 others); Tue, 8 Sep 2020 15:09:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:53538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731244AbgIHQGG (ORCPT ); Tue, 8 Sep 2020 12:06:06 -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 5346C23D9B; Tue, 8 Sep 2020 15:46:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579992; bh=74s5m8HNMKP17ED9i127nA+BSSpQ6KiM7FGWrO3friM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NKwclUCe4Ga7Sr5OcoLhT0eNgw1p7phK+VCy8QKw0A4R/kdA5yHbnLggNQ9NRQhU8 7LsOoJ2vXsTEN5iJux6sx22+ajM8weOn4ndLjINeo7FUe4YfRNxx/efd7dqNTUUmT7 LB5foA4cReN70NXUpKSDRJOHPjNoqqUc8IRaDSuk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ye Bin , Mike Snitzer Subject: [PATCH 5.4 117/129] dm cache metadata: Avoid returning cmd->bm wild pointer on error Date: Tue, 8 Sep 2020 17:25:58 +0200 Message-Id: <20200908152235.699970173@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152229.689878733@linuxfoundation.org> References: <20200908152229.689878733@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: 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 @@ -537,12 +537,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; }