From patchwork Thu Aug 2 07:37:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenjie6@huawei.com X-Patchwork-Id: 10553343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 805F013B4 for ; Thu, 2 Aug 2018 07:59:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77ACD2B527 for ; Thu, 2 Aug 2018 07:59:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B7CF2B6D6; Thu, 2 Aug 2018 07:59:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 440072B527 for ; Thu, 2 Aug 2018 07:59:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 200C06B0003; Thu, 2 Aug 2018 03:59:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 188E66B0005; Thu, 2 Aug 2018 03:59:36 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 053EE6B0006; Thu, 2 Aug 2018 03:59:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi0-f71.google.com (mail-oi0-f71.google.com [209.85.218.71]) by kanga.kvack.org (Postfix) with ESMTP id D17A76B0003 for ; Thu, 2 Aug 2018 03:59:35 -0400 (EDT) Received: by mail-oi0-f71.google.com with SMTP id m21-v6so1224660oic.7 for ; Thu, 02 Aug 2018 00:59:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:mime-version; bh=QOXxOl2dI++TqZW6VRs6oOfcsQtJRo3LBmYSzsQJ+9E=; b=ndtWdALGfGUMC5oqZq58ppz4qaNkWDnjB3hHidjqjXOeD26ARVhYo7ijlCnOKnhBlp i2rnoXQkj1XDJDomboOoAuiGSSWGSC/U619lH3dcZski1uJ0HlTQhMRnVL3WryF+YY3n r1FzrWKTqkqkuw34r8lS2Do/j763rgFKKDuVbylzybLzTnZuhaWtI3DC7uned75lSiIK BgGnczxR9mVih8LIx7cYTvJdJbz6UULvY2F/Q8ml0m5WS4HEiNIXOv9tolkBZ9usgR9N 55jIsnU+FkWwFbuhWfhs7iSDwyRp4w7iq3WtGElwneqoHA5XM8XuwWOkSCRiGzBP+QpZ 6Pew== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of chenjie6@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=chenjie6@huawei.com X-Gm-Message-State: AOUpUlGXc9TzFhGWwluXRg/ehSWToI7SDiylyfrfZlIrbrOtiT/tCp+T Jouo7oBjpwHyIKknoTgLWzWE057nTQ8VcbAHYY+rHNMZgldkVH8/+hqqVxmpP1vs3RLnfJXnqTf Chd5MyVYLqFtYv6ISwN70dk6EB91z3gwhhu30jIfwLRzbaqbJ4LNol6RtkcySS7VrTg== X-Received: by 2002:aca:c514:: with SMTP id v20-v6mr1790828oif.153.1533196775458; Thu, 02 Aug 2018 00:59:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdcHHDfcm+PiRNcxqpPdQMO04B+X1S0dhnWAYIOOy+WYsx217RVVuAfLk+kpeJ1x4MsYMpm X-Received: by 2002:aca:c514:: with SMTP id v20-v6mr1790797oif.153.1533196774795; Thu, 02 Aug 2018 00:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533196774; cv=none; d=google.com; s=arc-20160816; b=oo5BIqHrNlaqppc3mz5QgEzRQaXJ8v5Eosdts35RVGmNdOF5DyP/8f+8I8BdzfeGp4 FBPJ4REaH7DlomFW+V29aM1zg/Utz6GJ9nsNNYtDawWHqJ460l3VX3LQe4evn2loV/vJ 8CkaRdgPRBvVexUA82cjB5dh3IM6PiDv6Co82QGAvnd10JkcE+NL6SqeKIV2a/ShPU/A 4KJBjyBGryqvfCzWk8rjtMBMNZ3XeFGtr9GGL5pUxYUTMimZgB+95aO9itqFH+6kqhNi keLK1OBOtWSerignklsz6eHHVSyA7IoBIRSyy4wzoL+SfUQJg1K8qyDVaWVuXDm4mnhu jNig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:message-id:date:subject:cc:to:from :arc-authentication-results; bh=QOXxOl2dI++TqZW6VRs6oOfcsQtJRo3LBmYSzsQJ+9E=; b=m2wReg3dKqyaXIdYdA9S19F4IfI7naW5TH9uCxy2YqFmVLpcs45vbO1/+sR2i7c0ZJ Cb1p93fjVomnXf1KKYjkFBUUlqA3vy7U4KFKC8ra1Ds18CU5awEFeOCv1hAgj6ToxTax I69FsoZVFXQrruq7EAwP6C+RXWWaOGZOCUaydDtwLVNc95YAqlhDcpE0HeVbhw8zFIfm 8fHucWtErVO13YH7RSv4f2AgmvQi/yJiFGA69OzUuV2jC2deaCgTv0mlnZjgPBUkhf8B CWc56Lgfr9CMQA/QTIrOl4OmDRQhfppIKni0aNubSNVzkZRL9k3kL61PBLnLNBiEMapx CPlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of chenjie6@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=chenjie6@huawei.com Received: from huawei.com (szxga07-in.huawei.com. [45.249.212.35]) by mx.google.com with ESMTPS id y129-v6si855691oiy.462.2018.08.02.00.59.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Aug 2018 00:59:34 -0700 (PDT) Received-SPF: pass (google.com: domain of chenjie6@huawei.com designates 45.249.212.35 as permitted sender) client-ip=45.249.212.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of chenjie6@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=chenjie6@huawei.com Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E53278AE81895; Thu, 2 Aug 2018 15:58:59 +0800 (CST) Received: from linux-work.huawei.com (10.67.189.231) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.399.0; Thu, 2 Aug 2018 15:58:55 +0800 From: To: , CC: , , chen jie <"chen jie@chenjie6"@huwei.com>, chen jie Subject: [PATCH] mm:bugfix check return value of ioremap_prot Date: Thu, 2 Aug 2018 07:37:21 +0000 Message-ID: <1533195441-58594-1-git-send-email-chenjie6@huawei.com> X-Mailer: git-send-email 1.8.3.4 MIME-Version: 1.0 X-Originating-IP: [10.67.189.231] X-CFilter-Loop: Reflected X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: chen jie ioremap_prot can return NULL which could lead to an oops Signed-off-by: chen jie --- mm/memory.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memory.c b/mm/memory.c index 7206a63..316c42e 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4397,6 +4397,9 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr, return -EINVAL; maddr = ioremap_prot(phys_addr, PAGE_ALIGN(len + offset), prot); + if (!maddr) + return -ENOMEM; + if (write) memcpy_toio(maddr + offset, buf, len); else