Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp523590yba; Mon, 1 Apr 2019 11:02:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8t9oaNcW13M5VpRjlXV6JViR/PJj+gJ77Pah5jy/VqKuRiPEEMIWJrWjDnQz2tc1s/IG3 X-Received: by 2002:a63:fb16:: with SMTP id o22mr60572220pgh.209.1554141730185; Mon, 01 Apr 2019 11:02:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554141730; cv=none; d=google.com; s=arc-20160816; b=edt5B6zsxpSaJHvrg+SA3d6pBkk1bTCLUCoSggcxnGDJiqFlCBG+bc32svvbV1+XwU MzJ91g09VCNoUQQKwR4S9QnQycZYSK7NoupwEElKRc+pbbn4OUStxdi+H//UCyKA9iMV cwZdw3f1o0LeI1BXpXb5nfR3rPuZXMFszPzbeQp7u6QOXCl+MhU1x1CDX3KQJZGznv/J 8LHtG0Y/O9ctstEqzBG7BjSBS3Bef2UtfNpnOuUi+Xa1jyfreISzG9V1BWBFwvVIe/7c E82GQk4D7Zp9VNqiw/7xhORiB2iTrbDRZycMYpcd74QT+XTS2J8M5Gz7GvK49/TlliJW V/rw== 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=SutoRBFzR46Vjk8Sryg2tRPpnDA8llKQszGOMgpwepQ=; b=BtaBLwhD7cqfcORI+srDH+0bvHks+WKrTU7pgPlNp3B7WKUmbribNcP256wHywz713 kCYlo5mW0SSrt+a0beZ8dMyFHXb9bZQ7y4OTDqWGzgxWyRyGASGsEvzr0uoLjNjyHvxg Km46VT3fB/ZNmHXo3c4JD/iz/JgB++58H5qNsXK7q2nbqe0obJRRzbAll2jldCmSi4Tc T5xRPUtwwvG0m7A+2by7ha3hNF2bCjxkgn6pJGwUruBTrVd1WIMkyY1AnALbQUsJnSkx GOBPnLWRCNFGs0WzNK5WQc1vDUENKnxE4wuNg6ewGy2BYVvn5JuTa0TH/stptkua2e1+ RxNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hG8HGwVB; 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 d23si9021256pls.151.2019.04.01.11.01.54; Mon, 01 Apr 2019 11:02:10 -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=hG8HGwVB; 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 S1731080AbfDARQt (ORCPT + 99 others); Mon, 1 Apr 2019 13:16:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:42242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730894AbfDARQp (ORCPT ); Mon, 1 Apr 2019 13:16:45 -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 1497720856; Mon, 1 Apr 2019 17:16:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554139004; bh=9QjQF9i06KEdEvToiN9mkyWVjZGQlFSTh8Fj8NgzD9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hG8HGwVBi8/JrcQ2sqlrAHgDUDTHfsq3YmWj3sapoZQFFDLTfCC3b+uNcQmc1zvBq neQ0BRIPDL49vMqtGIk/r447M5R6lG9tgtorjsU2Li4tmeO/dYxakmWg25oAMuVgTe zDoM9XdgzVtdD08B08QUDcTS8qQ1k+jCOOPbeDV8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gao Xiang , Chao Yu Subject: [PATCH 4.19 085/134] staging: erofs: fix to handle error path of erofs_vmap() Date: Mon, 1 Apr 2019 19:02:01 +0200 Message-Id: <20190401170052.245368699@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401170044.243719205@linuxfoundation.org> References: <20190401170044.243719205@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chao Yu commit 8bce6dcede65139a087ff240127e3f3c01363eed upstream. erofs_vmap() wrapped vmap() and vm_map_ram() to return virtual continuous memory, but both of them can failed due to a lot of reason, previously, erofs_vmap()'s callers didn't handle them, which can potentially cause NULL pointer access, fix it. Fixes: 3883a79abd02 ("staging: erofs: introduce VLE decompression support") Fixes: 0d40d6e399c1 ("staging: erofs: add a generic z_erofs VLE decompressor") Cc: # 4.19+ Signed-off-by: Gao Xiang Signed-off-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 4 ++++ drivers/staging/erofs/unzip_vle_lz4.c | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -942,6 +942,10 @@ repeat: skip_allocpage: vout = erofs_vmap(pages, nr_pages); + if (!vout) { + err = -ENOMEM; + goto out; + } err = z_erofs_vle_unzip_vmap(compressed_pages, clusterpages, vout, llen, work->pageofs, overlapped); --- a/drivers/staging/erofs/unzip_vle_lz4.c +++ b/drivers/staging/erofs/unzip_vle_lz4.c @@ -116,10 +116,13 @@ int z_erofs_vle_unzip_fast_percpu(struct nr_pages = DIV_ROUND_UP(outlen + pageofs, PAGE_SIZE); - if (clusterpages == 1) + if (clusterpages == 1) { vin = kmap_atomic(compressed_pages[0]); - else + } else { vin = erofs_vmap(compressed_pages, clusterpages); + if (!vin) + return -ENOMEM; + } preempt_disable(); vout = erofs_pcpubuf[smp_processor_id()].data;