From patchwork Fri May 10 03:03:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 10938159 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 26F94912 for ; Fri, 10 May 2019 02:54:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15C4F28BBF for ; Fri, 10 May 2019 02:54:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0920C28BC6; Fri, 10 May 2019 02:54:22 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B29EA28BBF for ; Fri, 10 May 2019 02:54:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726945AbfEJCyJ (ORCPT ); Thu, 9 May 2019 22:54:09 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:58080 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726896AbfEJCyJ (ORCPT ); Thu, 9 May 2019 22:54:09 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id DCC6EBDE43C344F5926F; Fri, 10 May 2019 10:54:06 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Fri, 10 May 2019 10:53:56 +0800 From: Kefeng Wang To: CC: Kefeng Wang , Dmitry Torokhov , , Hulk Robot Subject: [PATCH 1/3] Input: apanel: avoid panic if ioreamp fails Date: Fri, 10 May 2019 11:03:18 +0800 Message-ID: <20190510030320.109154-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If ioremap fails, NULL pointer dereference will happen and leading to a kernel panic when access the virtual address in check_signature(). Fix it by check the return value of ioremap. Cc: Dmitry Torokhov Cc: linux-input@vger.kernel.org Reported-by: Hulk Robot Signed-off-by: Kefeng Wang --- drivers/input/misc/apanel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/input/misc/apanel.c b/drivers/input/misc/apanel.c index c1e66f45d552..1c7262ad4b5b 100644 --- a/drivers/input/misc/apanel.c +++ b/drivers/input/misc/apanel.c @@ -259,7 +259,9 @@ static int __init apanel_init(void) unsigned char i2c_addr; int found = 0; - bios = ioremap(0xF0000, 0x10000); /* Can't fail */ + bios = ioremap(0xF0000, 0x10000); + if (!bios) + return -ENOMEM; p = bios_signature(bios); if (!p) { From patchwork Fri May 10 03:03:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 10938157 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 C2C331515 for ; Fri, 10 May 2019 02:54:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99E4728BBF for ; Fri, 10 May 2019 02:54:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8730D28BC6; Fri, 10 May 2019 02:54:19 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7B1028BBF for ; Fri, 10 May 2019 02:54:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726806AbfEJCyN (ORCPT ); Thu, 9 May 2019 22:54:13 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:58084 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726864AbfEJCyJ (ORCPT ); Thu, 9 May 2019 22:54:09 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E457EF57247D1671A9A1; Fri, 10 May 2019 10:54:06 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Fri, 10 May 2019 10:53:57 +0800 From: Kefeng Wang To: CC: Kefeng Wang , Dmitry Torokhov , Miloslav Trmac , Wolfram Sang , , Hulk Robot Subject: [PATCH 2/3] Input: wistron_btns: avoid panic if ioreamp fails Date: Fri, 10 May 2019 11:03:19 +0800 Message-ID: <20190510030320.109154-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190510030320.109154-1-wangkefeng.wang@huawei.com> References: <20190510030320.109154-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If ioremap fails, NULL pointer dereference will happen and leading to a kernel panic when access the virtual address in check_signature(). Fix it by check the return value of ioremap. Cc: Dmitry Torokhov Cc: Miloslav Trmac Cc: Wolfram Sang Cc: linux-input@vger.kernel.org Reported-by: Hulk Robot Signed-off-by: Kefeng Wang --- drivers/input/misc/wistron_btns.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c index 43e67f546366..a82ec3d102b4 100644 --- a/drivers/input/misc/wistron_btns.c +++ b/drivers/input/misc/wistron_btns.c @@ -107,7 +107,10 @@ static int __init map_bios(void) ssize_t offset; u32 entry_point; - base = ioremap(0xF0000, 0x10000); /* Can't fail */ + base = ioremap(0xF0000, 0x10000); + if (!base) + return -ENOMEM; + offset = locate_wistron_bios(base); if (offset < 0) { printk(KERN_ERR "wistron_btns: BIOS entry point not found\n");