Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp326418pxk; Fri, 11 Sep 2020 08:01:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpmhTimD1C6s94wwJePcAE/ktFytMqxm8odiUai6/kX6tLZbaTOflF2fTap4TM9T2Up7iu X-Received: by 2002:a7b:c40b:: with SMTP id k11mr2571643wmi.135.1599836464747; Fri, 11 Sep 2020 08:01:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599836464; cv=none; d=google.com; s=arc-20160816; b=HFZeKrmq3qtccwXaUkWR5f7fk/3kvUco5YA9Ova3LdPoAhn760JgTCn6hU3iGlaeVt 1uLKScnpeNNuLOQI/ps2ZM6CleejUx10w5tlKfhUtOGoqTLy8lzWztrITaCC15r5UzqX 9KeMNWOXH8x6cda03tfWdvKp0DLuHtAtoe/djAD2pX3FN/C2/vlFSD0tMrN7rTgVqpzx +HsSY1xSux72D+GywsseCJqXYI61ML9WpGBZ/0g68Uxb3ln2oJN+2LImcKcwFRmwmdyW 8jS8KNfFMSkdajgg9jHYQ0UUnltRLbN/C6tuxy5//MjtUw9DDuSdl0IY09N09Im5Itfq 3Zzg== 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=WKmkdO/JWuPl/d/VxNuyRLMalMeRFA0deIQYESNLPT8=; b=rh9HqAqkd1R34MVvq7KK2hilRz8YCUbnIKdgvVR3kW650vzAnsVpxE7TFVwIEhLnQ+ 9KHuZZf/RdU5aWQYMBzDey3bYPfBPICkj0IqRL8oEfl49oEknBTiDfICRMaNzP/INUym 1WRPfjFPRYYxyeH+9JHLRp0SH8fAQeEJ6t/TOTpk75GbI0Ab6xNezoVbgeTAtvhztcf+ 0hmIT07WOwFKBq/pMAkfp9fonJqDmqe419+CHgH11etxRexXCQAwETwE4fNKAoY+Wvq5 xgTsJvCE3juLR71zPT6MskjiyPNLkO6fSPmJwxPLttd4Gpdqo/0mwArJVMheGm6O7v68 fOOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qeq5+Upz; 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 q20si1380496ejx.248.2020.09.11.08.00.40; Fri, 11 Sep 2020 08:01:04 -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=qeq5+Upz; 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 S1726119AbgIKO7W (ORCPT + 99 others); Fri, 11 Sep 2020 10:59:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:52784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726172AbgIKNCU (ORCPT ); Fri, 11 Sep 2020 09:02:20 -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 882F420758; Fri, 11 Sep 2020 12:57:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829048; bh=4BrAkly75xff2zeo4WjU3QguBwgx00EVmX1ImTV5x/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qeq5+UpzvVcm/1UoujyBkOgFBKhftoVvdwIZnhNXgVon1K1oO3H0rRKr+EFi0irwl UWW9YzmOIUJmj6r0fHjnL0YIfumfX5i49mwN/izry2iwu3lOOrbtM3nTboYoDh+GKZ vZrDNQGRPlCL6ugWjzjcty3mbotgg0bv9fH1wT18= 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.9 46/71] dm cache metadata: Avoid returning cmd->bm wild pointer on error Date: Fri, 11 Sep 2020 14:46:30 +0200 Message-Id: <20200911122507.216504913@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122504.928931589@linuxfoundation.org> References: <20200911122504.928931589@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 @@ -508,12 +508,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; }