From patchwork Mon Nov 14 07:54:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li RongQing X-Patchwork-Id: 125499 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8F01EB71F6 for ; Mon, 14 Nov 2011 18:54:22 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751846Ab1KNHyR (ORCPT ); Mon, 14 Nov 2011 02:54:17 -0500 Received: from mail-iy0-f174.google.com ([209.85.210.174]:44556 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751252Ab1KNHyQ (ORCPT ); Mon, 14 Nov 2011 02:54:16 -0500 Received: by iage36 with SMTP id e36so6935221iag.19 for ; Sun, 13 Nov 2011 23:54:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:x-mailer; bh=W+YnO5ctbeezlkcb3UPPyl1jdcEKIXE435zOaOtJ9lo=; b=IQf4KE2t16OAux6L/kdmLBr32aLwvkA9ulK3JuzNfXI9UlEiWrW2LBy6O79RWtxtAO QHPuOVK/OLOh3rxWDYFjklRCwAhxdv8JikIZaQb6uttyvXy6rlcR0e+g0qaqvigcCkCK 3GmXS9fBFwBjcYLceGb93k6X9bCauFQXG/tm0= Received: by 10.42.161.132 with SMTP id t4mr21696073icx.16.1321257256400; Sun, 13 Nov 2011 23:54:16 -0800 (PST) Received: from localhost ([61.148.56.138]) by mx.google.com with ESMTPS id z10sm29269906ibv.9.2011.11.13.23.54.14 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 13 Nov 2011 23:54:16 -0800 (PST) From: roy.qing.li@gmail.com To: netdev@vger.kernel.org Subject: [PATCH] ipv4: fix a memory leak in ic_bootp_send_if Date: Mon, 14 Nov 2011 15:54:08 +0800 Message-Id: <1321257248-14175-1-git-send-email-roy.qing.li@gmail.com> X-Mailer: git-send-email 1.7.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: RongQing.Li when dev_hard_header() failed, the newly allocated skb should be freed. Signed-off-by: RongQing.Li --- net/ipv4/ipconfig.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 0da2afc..7f17ba8 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -822,8 +822,13 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d skb->dev = dev; skb->protocol = htons(ETH_P_IP); if (dev_hard_header(skb, dev, ntohs(skb->protocol), - dev->broadcast, dev->dev_addr, skb->len) < 0 || - dev_queue_xmit(skb) < 0) + dev->broadcast, dev->dev_addr, skb->len) < 0) { + kfree_skb(skb); + printk("E"); + return; + } + + if (dev_queue_xmit(skb) < 0) printk("E"); }