From patchwork Tue Aug 22 01:07:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoming Ni X-Patchwork-Id: 9914043 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9B900600C5 for ; Tue, 22 Aug 2017 01:22:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D1DD287BD for ; Tue, 22 Aug 2017 01:22:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81E522881C; Tue, 22 Aug 2017 01:22:59 +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=-6.9 required=2.0 tests=BAYES_00,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 0DC8E2881D for ; Tue, 22 Aug 2017 01:22:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754467AbdHVBWc (ORCPT ); Mon, 21 Aug 2017 21:22:32 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4974 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754409AbdHVBWb (ORCPT ); Mon, 21 Aug 2017 21:22:31 -0400 Received: from 172.30.72.58 (EHLO DGGEMS414-HUB.china.huawei.com) ([172.30.72.58]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DFP85311; Tue, 22 Aug 2017 09:22:28 +0800 (CST) Received: from linux.huawei.com (10.67.187.180) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.301.0; Tue, 22 Aug 2017 09:22:27 +0800 From: nixiaoming To: , CC: , , Subject: [PATCH] virt/lib avoids oops by adding parameter checking Date: Tue, 22 Aug 2017 09:07:53 +0800 Message-ID: <20170822010753.102857-1-nixiaoming@huawei.com> X-Mailer: git-send-email 2.11.0.1 MIME-Version: 1.0 X-Originating-IP: [10.67.187.180] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.599B8755.0008, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: f9fc0af77c9a4a4c13fb95fc26b98781 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The error parameter passed through the external interface causes the system oops. So it is necessary to increase the parameter check for all EXPORT_SYMBOL_GPL example: int irq_bypass_register_producer(struct irq_bypass_producer *producer) { if (!producer->token) /* oops if producer == null */ return -einval; } EXPORT_SYMBOL_GPL(irq_bypass_register_producer); Signed-off-by: nixiaoming --- virt/lib/irqbypass.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/virt/lib/irqbypass.c b/virt/lib/irqbypass.c index 6d2fcd6..2bb99e8 100644 --- a/virt/lib/irqbypass.c +++ b/virt/lib/irqbypass.c @@ -89,7 +89,7 @@ int irq_bypass_register_producer(struct irq_bypass_producer *producer) struct irq_bypass_producer *tmp; struct irq_bypass_consumer *consumer; - if (!producer->token) + if (!producer || !producer->token) return -EINVAL; might_sleep(); @@ -139,7 +139,7 @@ void irq_bypass_unregister_producer(struct irq_bypass_producer *producer) struct irq_bypass_producer *tmp; struct irq_bypass_consumer *consumer; - if (!producer->token) + if (!producer || !producer->token) return; might_sleep(); @@ -183,7 +183,7 @@ int irq_bypass_register_consumer(struct irq_bypass_consumer *consumer) struct irq_bypass_consumer *tmp; struct irq_bypass_producer *producer; - if (!consumer->token || + if (!consumer || !consumer->token || !consumer->add_producer || !consumer->del_producer) return -EINVAL; @@ -234,7 +234,7 @@ void irq_bypass_unregister_consumer(struct irq_bypass_consumer *consumer) struct irq_bypass_consumer *tmp; struct irq_bypass_producer *producer; - if (!consumer->token) + if (!consumer || !consumer->token) return; might_sleep();