Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp331225pxk; Fri, 11 Sep 2020 08:07:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHBW0D+FwMTXe4m1R6LhxcfTh4lkLYS6lmrcrlJCfNQW3ltlqtrt6ybfnwQyU9Xx6ya0Rk X-Received: by 2002:a17:906:35d5:: with SMTP id p21mr2468725ejb.194.1599836823677; Fri, 11 Sep 2020 08:07:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599836823; cv=none; d=google.com; s=arc-20160816; b=YtvKlmQGIdOMF0ShDRqTOBjnGJNQnRAGoRx5s5EylY9iVhtM77h5lsgfwacFH+W/B1 1iB3AILJtt3GuMsc9e1u7W6iyrakv0/4E3suiaEscKzBfGQXjw5qLu8fDaBHeMmWcQRX kmqdtzL2N4/16LNXaNrPfuOWft4YksGZ8AX/lDOvQ5YqzjwVrMPXzTR9qs/u0b46Be6P lwEE/Wi5XunMJZo8wmd+B6B/y29npT50SOtIBaU1bZOKHI5jO1/IslEmlajgNlQcShpn cYw7Q4QpOHRw46mXaDUdNM5be0H0RoAypWk2Snd9/YnNIs3AVLxlGuvefion73veiFIL /cwQ== 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=ZHvmWJKkaTQmoQ8kYZ68dXBYD4OtmzoSo/WgmxlqQ2o=; b=sd+02hyhPrYRCH2LUw77CJgH8gGejb/Mg9Of5pb1ZmOjVgozSsAEt0XJbi6AupHSfh 4jldA0/wcGgsb2ncKpT3qhAXJuvvrEYp0l6zbDm1DzO0RnxCBaZUFL2HuMYkd26aRVZH +ZqChOp2iz5lX6VVPoWFjN1cer1Gq738dMizEzvLCZzQEdOQI0uegwl+dzVTkgZ/ntFp Yo5dmEKmtfjVK03ehFPZZNUfAHNlwqfwaFwMwdqMeGy/foxYXv7c/i6i3tHoUgMMeoEv l4UU1zzizFBL1BUK3cS+iEnYzJW163lTGHvYSjDSiG8S0cQkTZcce9gGY5FlZWQ44bFD F00w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=isTATd3B; 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 f12si1439628ejf.82.2020.09.11.08.06.39; Fri, 11 Sep 2020 08:07:03 -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=isTATd3B; 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 S1725947AbgIKPBl (ORCPT + 99 others); Fri, 11 Sep 2020 11:01:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:54394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726181AbgIKNCU (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 0E43422242; Fri, 11 Sep 2020 12:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829050; bh=QE17evv1Y7ctaurvyQ7i62yO2vJYXzF22gW2hz51gUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=isTATd3BebxFqIwpN21cHbVMb8srW7cKBBC1TLYHzgktuIRAeNl2cjdYa8o3RXTfk WjAF8wNTfvCn7PqdvBObJMYxwMzqBQIy/ZK2icN1/4HqDHDdJenlwdQfO0rdFKuEdI H7XfPHYbI3sJzLlXKduQrh828xi0+cHvGt7M+Mlo= 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 47/71] dm thin metadata: Avoid returning cmd->bm wild pointer on error Date: Fri, 11 Sep 2020 14:46:31 +0200 Message-Id: <20200911122507.265553927@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 219403d7e56f9b716ad80ab87db85d29547ee73e 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-thin-metadata.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c @@ -700,12 +700,16 @@ static int __create_persistent_data_obje THIN_MAX_CONCURRENT_LOCKS); if (IS_ERR(pmd->bm)) { DMERR("could not create block manager"); - return PTR_ERR(pmd->bm); + r = PTR_ERR(pmd->bm); + pmd->bm = NULL; + return r; } r = __open_or_format_metadata(pmd, format_device); - if (r) + if (r) { dm_block_manager_destroy(pmd->bm); + pmd->bm = NULL; + } return r; }