From: Dietmar Hahn Subject: [PATCH]Mini-OS: Small fix for NULL pointer handling Date: Fri, 26 Jan 2007 14:35:43 +0100 Message-ID: <200701261435.43136.dietmar.hahn@fujitsu-siemens.com> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_vOguFYei2GG0kiT" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com Cc: xen-devel , Grzegorz Milos List-Id: xen-devel@lists.xenproject.org --Boundary-00=_vOguFYei2GG0kiT Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Gregor, attached is a small patch for netfront.c. A compiler warning is fixed when -O? is used. If the network is not configured, backend gets NULL from xenbus_read() and this leads sometimes to a crash because this pointer is used later. I hope this fix is OK. Please have a look and send comments! Thanks. Dietmar. --Boundary-00=_vOguFYei2GG0kiT Content-Type: text/x-diff; charset="iso-8859-15"; name="mini-os.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="mini-os.patch" # HG changeset patch # User dietmar.hahn@fujitsu-siemens.com # Date 1169817843 -3600 # Node ID 6d4800573fd7d97c4b007d3dc9f89bf883605063 # Parent 82c306ad212e3714cf9292611a0ddb8de7a3b5dc Signed-off-by: Dietmar Hahn - Handle returned backend==NULL || mac==NULL, this leads sometimes to a crash. - Handle initializing of np->rx.req_prod_pvt to avoid a compiler warning when using -O?. diff -r 82c306ad212e -r 6d4800573fd7 extras/mini-os/netfront.c --- a/extras/mini-os/netfront.c Thu Jan 25 10:34:17 2007 +0000 +++ b/extras/mini-os/netfront.c Fri Jan 26 14:24:03 2007 +0100 @@ -324,6 +324,14 @@ done: msg = xenbus_read(XBT_NIL, "device/vif/0/backend", &backend); msg = xenbus_read(XBT_NIL, "device/vif/0/mac", &mac); + if((backend == NULL) || (mac == NULL)) { + struct evtchn_close op = { info->local_port }; + printk("%s: backend/mac failed\n", __func__); + unbind_evtchn(info->local_port); + HYPERVISOR_event_channel_op(EVTCHNOP_close, &op); + return; + } + printk("backend at %s\n",backend); printk("mac is %s\n",mac); @@ -383,8 +391,10 @@ void init_rx_buffers(void) netif_rx_request_t *req; int notify; - np->rx.req_prod_pvt = requeue_idx; - + /* Initializing with 0 to avoid a cc warning with -O?, but + * initializing mmust be! */ + //np->rx.req_prod_pvt = requeue_idx; + np->rx.req_prod_pvt = 0; /* Step 2: Rebuild the RX buffer freelist and the RX ring itself. */ for (requeue_idx = 0, i = 0; i < NET_RX_RING_SIZE; i++) --Boundary-00=_vOguFYei2GG0kiT Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_vOguFYei2GG0kiT--