Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4159333pxk; Tue, 8 Sep 2020 12:11:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxD0zz+iBx/Z+5AL0ZwEdMGp+XKBEQ2pyjMMj3sshprPpJjSkJheMnwGtSYgbbqELnDvBD X-Received: by 2002:a17:906:f1cf:: with SMTP id gx15mr27098046ejb.241.1599592294951; Tue, 08 Sep 2020 12:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599592294; cv=none; d=google.com; s=arc-20160816; b=nymzd3/T8TSVZLjS8/XVywrdAHVn1y+/QwA6BeYkp49GI7S17COZ6RcAcruMBKg9Vf HOBe5IJrp8kXb18jspP0YAu8QBZs9xySqDDALH2OzY6YKJqAM/SZfrWMGknj21mH8kGr 6V7cL6+DHYr0jlUaA6Qji5VTUNDFd1KnRJPU1d1M47Sc8pGPdzycMay7AVqq2y1jmfwo 1kGCqmWOmCVl3I3zBHbEnf2afwvYC6V4M1/mHkfJys00fmXdt4oxtBHLX/7qhAyp2c/9 XPA4wNUWQyPYfXDWOMRaSlyeDzAn1Z8vtbsR72n++JuO9Ni3aHkjSJ/laBazdS6+NfXU VeXw== 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=UqJr5m6xFgvm8B5Cs3NcAqEQzE4vd/bhJknTDgzAiCQ=; b=QxKD+vXxyQZp5XQ3ytkNhCDgJlRVqucDJPIQe2RvNdykimwGhuw/ptTTjHMPTFnU5k /EOMLqQwSeFxuy/r6eZtHMuY4RQw29hEW0E/skRCsQr4aiHZfdQeVLFAbi3tNeNM7dZP 1Fwa3hmKP5pNm+MFckvpuqXRdUSgf4e/pARiuAU8SaDaeZwJ3gQ7QYDmQvoVHcfouQrE pGbFMoHt30RGYQCWkqOVqk/V1cOfitpU1Wp7whmreXJtklz2SZlojO8i0PB+q+Mx9m+M Qm+Ms8+PLcGaCwqq0QXd9dI5C5qVB8qclfHWJ/q1WfbqWGebKAujednFfgRMf10sEM1R suow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C5GzVT1e; 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 x25si11786918edr.508.2020.09.08.12.11.12; Tue, 08 Sep 2020 12:11:34 -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=C5GzVT1e; 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 S1731688AbgIHTJl (ORCPT + 99 others); Tue, 8 Sep 2020 15:09:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:53536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730532AbgIHQGG (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 CAE2523DB3; Tue, 8 Sep 2020 15:46:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579995; bh=YZtkJSEijSSoBIAR5gokSABzm8BeI5DjS+qu+jTiRe4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C5GzVT1eFw7+AZwMjs8/gFUd6VXGI4/ddZSGpqMvtznQHnNdl82YLgv5HVtYFXVf4 boqdomP2jYDczZn9WAA6rJLa/VqK/6NgQFqyMFC4DG4cAD4TyaDDZIpfgFHUXizmIE Q3bl1S6PQGTMeAZiQt1aJu+nzjv88ZyjAESVsT8w= 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 118/129] dm thin metadata: Avoid returning cmd->bm wild pointer on error Date: Tue, 8 Sep 2020 17:25:59 +0200 Message-Id: <20200908152235.750106059@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 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 @@ -739,12 +739,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; }