All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel]  [PATCH v3] net: Fix a potential segfault
@ 2018-06-11  9:23 Lin Ma
  2018-06-11  9:48 ` Thomas Huth
  0 siblings, 1 reply; 3+ messages in thread
From: Lin Ma @ 2018-06-11  9:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: thuth, jasowang, Lin Ma

If user forgets to provide any backend types for '-netdev' in qemu CLI,
It triggers seg fault.

e.g.

Expected:
$ qemu -netdev id=net0
qemu-system-x86_64: Parameter 'type' is missing

Actual:
$ qemu -netdev id=net0
Segmentation fault (core dumped)

Signed-off-by: Lin Ma <lma@suse.com>
---
 net/net.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/net.c b/net/net.c
index efb9eaf779..2a3133990c 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1093,7 +1093,9 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
     int ret = -1;
     Visitor *v = opts_visitor_new(opts);
 
-    if (is_netdev && is_help_option(qemu_opt_get(opts, "type"))) {
+    const char *type = qemu_opt_get(opts, "type");
+
+    if (is_netdev && type && is_help_option(type)) {
         show_netdevs();
         exit(0);
     } else {
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v3] net: Fix a potential segfault
  2018-06-11  9:23 [Qemu-devel] [PATCH v3] net: Fix a potential segfault Lin Ma
@ 2018-06-11  9:48 ` Thomas Huth
  2018-06-12  2:03   ` Jason Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Huth @ 2018-06-11  9:48 UTC (permalink / raw)
  To: Lin Ma, qemu-devel; +Cc: jasowang

On 11.06.2018 11:23, Lin Ma wrote:
> If user forgets to provide any backend types for '-netdev' in qemu CLI,
> It triggers seg fault.
> 
> e.g.
> 
> Expected:
> $ qemu -netdev id=net0
> qemu-system-x86_64: Parameter 'type' is missing
> 
> Actual:
> $ qemu -netdev id=net0
> Segmentation fault (core dumped)
> 
> Signed-off-by: Lin Ma <lma@suse.com>
> ---
>  net/net.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/net/net.c b/net/net.c
> index efb9eaf779..2a3133990c 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -1093,7 +1093,9 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
>      int ret = -1;
>      Visitor *v = opts_visitor_new(opts);
>  
> -    if (is_netdev && is_help_option(qemu_opt_get(opts, "type"))) {
> +    const char *type = qemu_opt_get(opts, "type");
> +
> +    if (is_netdev && type && is_help_option(type)) {
>          show_netdevs();
>          exit(0);
>      } else {
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v3] net: Fix a potential segfault
  2018-06-11  9:48 ` Thomas Huth
@ 2018-06-12  2:03   ` Jason Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Wang @ 2018-06-12  2:03 UTC (permalink / raw)
  To: Thomas Huth, Lin Ma, qemu-devel



On 2018年06月11日 17:48, Thomas Huth wrote:
> On 11.06.2018 11:23, Lin Ma wrote:
>> If user forgets to provide any backend types for '-netdev' in qemu CLI,
>> It triggers seg fault.
>>
>> e.g.
>>
>> Expected:
>> $ qemu -netdev id=net0
>> qemu-system-x86_64: Parameter 'type' is missing
>>
>> Actual:
>> $ qemu -netdev id=net0
>> Segmentation fault (core dumped)
>>
>> Signed-off-by: Lin Ma <lma@suse.com>
>> ---
>>   net/net.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/net.c b/net/net.c
>> index efb9eaf779..2a3133990c 100644
>> --- a/net/net.c
>> +++ b/net/net.c
>> @@ -1093,7 +1093,9 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
>>       int ret = -1;
>>       Visitor *v = opts_visitor_new(opts);
>>   
>> -    if (is_netdev && is_help_option(qemu_opt_get(opts, "type"))) {
>> +    const char *type = qemu_opt_get(opts, "type");
>> +
>> +    if (is_netdev && type && is_help_option(type)) {
>>           show_netdevs();
>>           exit(0);
>>       } else {
>>
> Reviewed-by: Thomas Huth <thuth@redhat.com>

Applied, and queued for -stable.

Thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-12  2:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-11  9:23 [Qemu-devel] [PATCH v3] net: Fix a potential segfault Lin Ma
2018-06-11  9:48 ` Thomas Huth
2018-06-12  2:03   ` Jason Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.