Received: from eggs.gnu.org ([2001:4830:134:3::10]:52486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YG9jc-0000pO-Aq for qemu-devel@nongnu.org; Tue, 27 Jan 2015 12:15:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YG9jX-0007Ii-95 for qemu-devel@nongnu.org; Tue, 27 Jan 2015 12:15:28 -0500 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:59766) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YG9jX-0007IT-0R for qemu-devel@nongnu.org; Tue, 27 Jan 2015 12:15:23 -0500 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 27 Jan 2015 17:15:21 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id BD81917D8059 for ; Tue, 27 Jan 2015 17:15:22 +0000 (GMT) Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t0RHFHGq3539270 for ; Tue, 27 Jan 2015 17:15:17 GMT Received: from d06av12.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t0RHFHRN008898 for ; Tue, 27 Jan 2015 10:15:17 -0700 Date: Tue, 27 Jan 2015 18:15:16 +0100 From: Thomas Huth Message-ID: <20150127181516.27ab8e9d@oc7435384737.ibm.com> In-Reply-To: <1422376711-31648-3-git-send-email-armbru@redhat.com> References: <1422376711-31648-1-git-send-email-armbru@redhat.com> <1422376711-31648-3-git-send-email-armbru@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/6] rtl8139: g_malloc() can't fail, bury dead error handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-trivial@redhat.com, qemu-devel@nongnu.org On Tue, 27 Jan 2015 17:38:27 +0100 Markus Armbruster wrote: > Signed-off-by: Markus Armbruster > --- > hw/net/rtl8139.c | 14 -------------- > 1 file changed, 14 deletions(-) > > diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c > index 6fa9e0a..b55e438 100644 > --- a/hw/net/rtl8139.c > +++ b/hw/net/rtl8139.c > @@ -2075,20 +2075,6 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s) > "length to %d\n", txsize); > } > > - if (!s->cplus_txbuffer) > - { > - /* out of memory */ > - > - DPRINTF("+++ C+ mode transmiter failed to reallocate %d bytes\n", > - s->cplus_txbuffer_len); > - > - /* update tally counter */ > - ++s->tally_counters.TxERR; > - ++s->tally_counters.TxAbt; > - > - return 0; > - } > - > /* append more data to the packet */ > > DPRINTF("+++ C+ mode transmit reading %d bytes from host memory at " Wouldn't it be better to use g_try_malloc() here instead? If the code can handle OOM conditions, I think it's better to continue with a lost packet here than to shut down QEMU the hard way. (Also looking at the history of that file, the code originally used qemu_malloc() which could fail - but instead of being replaced by g_try_malloc(), it got replaced with g_malloc() instead which was maybe the wrong decision). Thomas