From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuxrL-0002IP-2K for qemu-devel@nongnu.org; Thu, 12 Jun 2014 01:47:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuxrE-0006yN-RH for qemu-devel@nongnu.org; Thu, 12 Jun 2014 01:47:35 -0400 Message-ID: <53993EED.5040408@siemens.com> Date: Thu, 12 Jun 2014 07:47:25 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <1384700688-30377-1-git-send-email-samuel.thibault@ens-lyon.org> <1392124097-10618-1-git-send-email-samuel.thibault@ens-lyon.org> <1392124097-10618-2-git-send-email-samuel.thibault@ens-lyon.org> <20140611085553.GO31888@type> In-Reply-To: <20140611085553.GO31888@type> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] slirp: goto bad in udp_input if sosendto fails List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Samuel Thibault , qemu-devel@nongnu.org Cc: edgar.iglesias@gmail.com, Guillaume Subiron On 2014-06-11 10:55, Samuel Thibault wrote: > Before this patch, if sosendto fails, udp_input is executed as if the > packet was sent. This could cause memory leak. Cannot follow yet how this could leak (not saying I fully got what it should NOT leak - nasty code). Can you elaborate on the before/after? Jan > This patch adds a goto bad to cut the execution of this function. > > Signed-off-by: Guillaume Subiron > --- > slirp/udp.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/slirp/udp.c b/slirp/udp.c > index 8cc6cb6..fd2446a 100644 > --- a/slirp/udp.c > +++ b/slirp/udp.c > @@ -218,6 +218,7 @@ udp_input(register struct mbuf *m, int iphlen) > *ip=save_ip; > DEBUG_MISC((dfd,"udp tx errno = %d-%s\n",errno,strerror(errno))); > icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno)); > + goto bad; > } > > m_free(so->so_m); /* used for ICMP if error on sorecvfrom */ > -- Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux