From patchwork Thu Aug 20 09:21:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 265436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EDAAC433DF for ; Thu, 20 Aug 2020 12:32:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 54C1E20738 for ; Thu, 20 Aug 2020 12:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597926729; bh=Q1zIU5SuzkyJ10BIgp1gFKULbwqkncB9RaWdhQ0CRdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OJ+wUrGVgvl3SBTlJkXFeRcrOs+wjOew645A5T69c8vwJ2KvCtB5yZa2ZAFy8V0en ejJ5mYX98Kg+QUI+DJjdb8hM/tCFpQOshXUYTpp2MGcjJ4S9vJpxH/jULOGxM+xGSS X4Zwjy6HCD3VRWDFR0OcoNeQBk//UE95clqO09qU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729101AbgHTMcH (ORCPT ); Thu, 20 Aug 2020 08:32:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:57350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729698AbgHTJuJ (ORCPT ); Thu, 20 Aug 2020 05:50:09 -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 39F422173E; Thu, 20 Aug 2020 09:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597917008; bh=Q1zIU5SuzkyJ10BIgp1gFKULbwqkncB9RaWdhQ0CRdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2Ex1hx5UmGr5tJaGKvEBqxg87TxiNuZ5K1Luu4xrul67JvzUKztaV7JY3A6MUvN2+ rzz0UNau437FXCw8xT7QVADPw6jwzMIGFu5pCvizcB8myzqIMTbMNHPskic+yOKMEH amBLXpOgmgU4YPNkQHTjzFxxqb+rdgSfYptHtsYo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Guoqing Jiang , Song Liu , Sasha Levin Subject: [PATCH 5.4 124/152] md-cluster: Fix potential error pointer dereference in resize_bitmaps() Date: Thu, 20 Aug 2020 11:21:31 +0200 Message-Id: <20200820091600.147128687@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091553.615456912@linuxfoundation.org> References: <20200820091553.615456912@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dan Carpenter [ Upstream commit e8abe1de43dac658dacbd04a4543e0c988a8d386 ] The error handling calls md_bitmap_free(bitmap) which checks for NULL but will Oops if we pass an error pointer. Let's set "bitmap" to NULL on this error path. Fixes: afd756286083 ("md-cluster/raid10: resize all the bitmaps before start reshape") Signed-off-by: Dan Carpenter Reviewed-by: Guoqing Jiang Signed-off-by: Song Liu Signed-off-by: Sasha Levin --- drivers/md/md-cluster.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c index 73fd50e779754..d50737ec40394 100644 --- a/drivers/md/md-cluster.c +++ b/drivers/md/md-cluster.c @@ -1139,6 +1139,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz bitmap = get_bitmap_from_slot(mddev, i); if (IS_ERR(bitmap)) { pr_err("can't get bitmap from slot %d\n", i); + bitmap = NULL; goto out; } counts = &bitmap->counts;