Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5236100ybl; Tue, 27 Aug 2019 01:17:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZSeFYnCNm2qpBmjK+5jVjC3Q05mUWhDLkmiU4V04hM8eB0IFp9iV3mKyZFzuwtGK549Rr X-Received: by 2002:a17:902:b40c:: with SMTP id x12mr23092932plr.81.1566893869198; Tue, 27 Aug 2019 01:17:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566893869; cv=none; d=google.com; s=arc-20160816; b=OhOQjRPTNbfdVV36qUQ7T63wKyWA3gFsk+M/wi1uoYYvKQofCF0JNaIzuEonuq7q3o hJ9fOtTi9VKnhDcwma4Rp3BnZgHVlrUQ2nUqBPo7u8TD5dix596ynTMI+b8uIZD7/BTz BCa2pIWGBW98lFthbLeOciv46EmilHv/NY5hDKpQciOvy6Kpi0TtvI7/5AAl2CZrEmVm 3PmfUfZsKg2pEKBuQz0XEBVppGkg6whMo3I2dzO08rD+XQ8122ov47fAyFtflJfsvC1V ZvNBpps7NeQoQWgO0UQAcMtXOvzdBrCWCGn8x4USGLPYT7oLqyFo5QbR562Nm806oFIo F95g== 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=xpnAdZqLz4IYZhIGcQQFiFk1PTNzdAEaUySS89AaYTg=; b=LnGvh1dvK4luGi6sBomlDXsqYbzBcLn16Mire804W6K/oC3DElmfYTZpYb8Og+7Ial u9x2tgdrZwWUURBOPtO+KzFmeQwD/g1XZbtNz2eTlgeTmWdxL1s0tMbEowNAFxCYlwX8 nAhNa0GdoUIHT6kcKNxvw1COjrfG/8n2EiJ9nk9QeCZ5RJeJ4bdPcFA4ioPwSiC8iN7u dsHTuXdIwr9vfvrlv5ZjfGuhY2HEK2ZivcSHwUh3CCcRbUFIPvmuBzd335BtiqbozIsw MI8RMaLStuF65bzoYnhRJbTo1fwQ0wFLCPLwLTEpc+T50Ji++CST9bAdMHSjqLMC/00+ km1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ODgdSnGX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e14si5581775pfn.199.2019.08.27.01.17.33; Tue, 27 Aug 2019 01:17:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ODgdSnGX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730116AbfH0Hyl (ORCPT + 99 others); Tue, 27 Aug 2019 03:54:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:46328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730098AbfH0Hyi (ORCPT ); Tue, 27 Aug 2019 03:54:38 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 5F9F4217F5; Tue, 27 Aug 2019 07:54:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566892477; bh=Ojiw9cviong+gOk0b1dDRq8ifWqinuxu2WAYzxvhGso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ODgdSnGXAdb/pl3w05FB6123gyTxqwk0+IH0xIYZRweSU03vnXXMTvkJ5/EZ1Tk6P S1TWNxrGF1m67JgRKssEgdIk8NYZ7rLWEppXgVK2D6CIze1RTWuj/2qtK1+LIUB7LU S+wjss4okF8SShkYWhjObOjMiSDMcXMA3p0n2Rx4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Dmitry Fomichev , Mike Snitzer , Sasha Levin Subject: [PATCH 4.14 61/62] dm zoned: fix potential NULL dereference in dmz_do_reclaim() Date: Tue, 27 Aug 2019 09:51:06 +0200 Message-Id: <20190827072704.012827908@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827072659.803647352@linuxfoundation.org> References: <20190827072659.803647352@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 [ Upstream commit e0702d90b79d430b0ccc276ead4f88440bb51352 ] This function is supposed to return error pointers so it matches the dmz_get_rnd_zone_for_reclaim() function. The current code could lead to a NULL dereference in dmz_do_reclaim() Fixes: b234c6d7a703 ("dm zoned: improve error handling in reclaim") Signed-off-by: Dan Carpenter Reviewed-by: Dmitry Fomichev Signed-off-by: Mike Snitzer Signed-off-by: Sasha Levin --- drivers/md/dm-zoned-metadata.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c index ccf17eb6adaa2..b322821a6323b 100644 --- a/drivers/md/dm-zoned-metadata.c +++ b/drivers/md/dm-zoned-metadata.c @@ -1579,7 +1579,7 @@ static struct dm_zone *dmz_get_seq_zone_for_reclaim(struct dmz_metadata *zmd) struct dm_zone *zone; if (list_empty(&zmd->map_seq_list)) - return NULL; + return ERR_PTR(-EBUSY); list_for_each_entry(zone, &zmd->map_seq_list, link) { if (!zone->bzone) @@ -1588,7 +1588,7 @@ static struct dm_zone *dmz_get_seq_zone_for_reclaim(struct dmz_metadata *zmd) return zone; } - return NULL; + return ERR_PTR(-EBUSY); } /* -- 2.20.1