Patchwork [for-1.4] net: Avoid NULL function pointer dereference on cleanup

login
register
mail settings
Submitter Andreas Färber
Date Feb. 12, 2013, 10:16 p.m.
Message ID <1360707366-9271-1-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/219997/
State New
Headers show

Comments

Andreas Färber - Feb. 12, 2013, 10:16 p.m.
The pSeries machine and some other devices don't supply a cleanup
callback. Revert part of 1ceef9f27359cbe92ef124bf74de6f792e71f6fb that
started calling it unconditionally.

Cc: Jason Wang <jasowang@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 net/net.c |    4 +++-
 1 Datei geändert, 3 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
David Gibson - Feb. 12, 2013, 11:13 p.m.
On Tue, Feb 12, 2013 at 11:16:06PM +0100, Andreas Färber wrote:
> The pSeries machine and some other devices don't supply a cleanup
> callback. Revert part of 1ceef9f27359cbe92ef124bf74de6f792e71f6fb that
> started calling it unconditionally.

Note that Alex Graf has now accepted a patch from me which adds a
cleanup callback to pseries.  I expect this is still a good idea for
the other cases, though.
Alexander Graf - Feb. 13, 2013, 5:44 a.m.
Am 13.02.2013 um 00:13 schrieb David Gibson <dwg@au1.ibm.com>:

> On Tue, Feb 12, 2013 at 11:16:06PM +0100, Andreas Färber wrote:
>> The pSeries machine and some other devices don't supply a cleanup
>> callback. Revert part of 1ceef9f27359cbe92ef124bf74de6f792e71f6fb that
>> started calling it unconditionally.
> 
> Note that Alex Graf has now accepted a patch from me which adds a
> cleanup callback to pseries.  I expect this is still a good idea for
> the other cases, though.

But only for 1.5. 1.4 should simply get this one applied.

Alex

> 
> -- 
> David Gibson            | I'll have my music baroque, and my code
> david AT gibson.dropbear.id.au    | minimalist, thank you.  NOT _the_ _other_
>                | _way_ _around_!
> http://www.ozlabs.org/~dgibson
Stefan Hajnoczi - Feb. 13, 2013, 8:38 a.m.
On Tue, Feb 12, 2013 at 11:16:06PM +0100, Andreas Färber wrote:
> The pSeries machine and some other devices don't supply a cleanup
> callback. Revert part of 1ceef9f27359cbe92ef124bf74de6f792e71f6fb that
> started calling it unconditionally.
> 
> Cc: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
>  net/net.c |    4 +++-
>  1 Datei geändert, 3 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)

Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Anthony Liguori - Feb. 18, 2013, 4:02 p.m.
Applied.  Thanks.

Regards,

Anthony Liguori

Patch

diff --git a/net/net.c b/net/net.c
index f9e7136..be03a8d 100644
--- a/net/net.c
+++ b/net/net.c
@@ -287,7 +287,9 @@  static void qemu_cleanup_net_client(NetClientState *nc)
 {
     QTAILQ_REMOVE(&net_clients, nc, next);
 
-    nc->info->cleanup(nc);
+    if (nc->info->cleanup) {
+        nc->info->cleanup(nc);
+    }
 }
 
 static void qemu_free_net_client(NetClientState *nc)