From: nixiaoming <nixiaoming-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
pbonzini-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH] virt/lib avoids oops by adding parameter checking
Date: Tue, 22 Aug 2017 09:07:53 +0800 [thread overview]
Message-ID: <20170822010753.102857-1-nixiaoming@huawei.com> (raw)
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 <nixiaoming-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
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();
--
2.11.0.1
next reply other threads:[~2017-08-22 1:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-22 1:07 nixiaoming [this message]
2017-08-22 13:39 ` [PATCH] virt/lib avoids oops by adding parameter checking Paolo Bonzini
2017-08-22 17:16 ` Alex Williamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170822010753.102857-1-nixiaoming@huawei.com \
--to=nixiaoming-hv44wf8li93qt0dzr+alfa@public.gmane.org \
--cc=alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=pbonzini-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox