Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp799668ybe; Fri, 13 Sep 2019 06:34:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6LiqullcmAP76zZZU4LbSJSi5cMywvG8sEC1pAmnyimwDFpxilRnhJauYAWCfnc0/CEZy X-Received: by 2002:a50:981b:: with SMTP id g27mr47838261edb.105.1568381678506; Fri, 13 Sep 2019 06:34:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568381678; cv=none; d=google.com; s=arc-20160816; b=UCZvNNroPxQLXbeieZXAbpiYTAYzTSNYVVx8YDsQJpv9kUsEqVY9ZT4eTw2+cQ0ixg HjdgYdmXM+GEmkozSNiYNvuD84JJUt+IjNErMs5ShC99aGf5X6qitguYzg7dXE+PESMJ J+PFvcRpl/3hmdZ48u68rJhDcJ/6dswLI4DEQPXXIw9QQWiQCjNTQ9YIDfbwUC0A+7WC OaH5o/+KhAxN3PccR7MIbj3aI6mWnwNBVkN936kC06d9vlQHVE4NuF+18boTl053vAyk YrOuAIf2pY1Z7KTyzKw1idgruXZk0LbS8f/nN6aZHBzH+MjJe4dHNSr/zi1CU0UuREVu /2Uw== 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=OckJ94YOOyibNqOuNhd5wHMQ55aTy4tRRprC4Cqg+nE=; b=Tm7QtArAGdNqpabnG7jNjfjHDikDfx+nHQGDC8kB9X3InzoMqQYga4p2hCzBt9zCDX Lty1//2fxbPwnAcxj4hufMfR/uFcaVV8+95oOZZDH046cgChyuMussv7e5rijwm+nkeU C9Tbqs6IPGY2IbWqGsEDsEpKE+62dOHZNBbqpkODIs2FLymweiZfrVeVmllIW+OuFye5 pVjtojLdqZrYFUAArIkqk5dcVd3B2Dx/vXpmVKBQ0NX7dKlyYlmEQeg08ykri6s058Sk HZrOijnTUYg9jFY++Q/EZtEzGynfbIUoSwgj7cD5HOIYPqPmPc3cdf8jb1i7wBzua0oH 1S1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MWSqJGRU; 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 o21si10819285edq.65.2019.09.13.06.34.15; Fri, 13 Sep 2019 06:34:38 -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=MWSqJGRU; 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 S2389769AbfIMNP7 (ORCPT + 99 others); Fri, 13 Sep 2019 09:15:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:42308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389198AbfIMNPz (ORCPT ); Fri, 13 Sep 2019 09:15:55 -0400 Received: from localhost (unknown [104.132.45.99]) (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 ECE9B206BB; Fri, 13 Sep 2019 13:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568380554; bh=U0wNzKNYCMHHDFndm0nBkAk0ouQ99rkHQ5WSLEg6I8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MWSqJGRUstOCbMSpvrU4m5GdHxnDMUbbPYjryYa/40aAH6jO542ZUmS0I6Opm9j3C zjbzmH3Rlzrsfv3SOfMb+kXhKF3H/H5wVhHZgYKtgWVTCzg6DVE1fICJdJ+Ls4xMi6 bbbbBnjI/foPOmy+9G8VJ1Ho4LCPznU2rqSOhra0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , Dan Robertson , David Sterba , Sasha Levin Subject: [PATCH 4.19 102/190] btrfs: init csum_list before possible free Date: Fri, 13 Sep 2019 14:05:57 +0100 Message-Id: <20190913130607.741324726@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913130559.669563815@linuxfoundation.org> References: <20190913130559.669563815@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 e49be14b8d80e23bb7c53d78c21717a474ade76b ] The scrub_ctx csum_list member must be initialized before scrub_free_ctx is called. If the csum_list is not initialized beforehand, the list_empty call in scrub_free_csums will result in a null deref if the allocation fails in the for loop. Fixes: a2de733c78fa ("btrfs: scrub") CC: stable@vger.kernel.org # 3.0+ Reviewed-by: Nikolay Borisov Signed-off-by: Dan Robertson Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/scrub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index a08a4d6f540f9..916c397704679 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -592,6 +592,7 @@ static noinline_for_stack struct scrub_ctx *scrub_setup_ctx( sctx->pages_per_rd_bio = SCRUB_PAGES_PER_RD_BIO; sctx->curr = -1; sctx->fs_info = fs_info; + INIT_LIST_HEAD(&sctx->csum_list); for (i = 0; i < SCRUB_BIOS_PER_SCTX; ++i) { struct scrub_bio *sbio; @@ -616,7 +617,6 @@ static noinline_for_stack struct scrub_ctx *scrub_setup_ctx( atomic_set(&sctx->workers_pending, 0); atomic_set(&sctx->cancel_req, 0); sctx->csum_size = btrfs_super_csum_size(fs_info->super_copy); - INIT_LIST_HEAD(&sctx->csum_list); spin_lock_init(&sctx->list_lock); spin_lock_init(&sctx->stat_lock); -- 2.20.1