From patchwork Mon Oct 24 22:01:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Juhl X-Patchwork-Id: 121428 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 2ADE2B6F7E for ; Tue, 25 Oct 2011 08:56:47 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756077Ab1JXV43 (ORCPT ); Mon, 24 Oct 2011 17:56:29 -0400 Received: from swampdragon.chaosbits.net ([90.184.90.115]:12755 "EHLO swampdragon.chaosbits.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754355Ab1JXV42 (ORCPT ); Mon, 24 Oct 2011 17:56:28 -0400 Received: by swampdragon.chaosbits.net (Postfix, from userid 1000) id 179A19403D; Tue, 25 Oct 2011 00:01:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by swampdragon.chaosbits.net (Postfix) with ESMTP id 10EEE9403B; Tue, 25 Oct 2011 00:01:00 +0200 (CEST) Date: Tue, 25 Oct 2011 00:01:00 +0200 (CEST) From: Jesper Juhl To: netdev@vger.kernel.org cc: linux-kernel@vger.kernel.org, "David S. Miller" , Sjur Braendeland Subject: [PATCH] caif: fix cfcnfg_add_phy_layer() leaks Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There are two locations where we 'goto out' after having allocated memory for 'phyinfo' but have not yet assigned it to anything. At the 'out:' label we'll exit from the function and 'phyinfo' will go out of scope and thus we leak the memory we allocated. This patch frees the memory before jumping to 'out:', thus fixing the leaks. Signed-off-by: Jesper Juhl --- net/caif/cfcnfg.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) compile tested only. diff --git a/net/caif/cfcnfg.c b/net/caif/cfcnfg.c index 52fe33b..b25dc02 100644 --- a/net/caif/cfcnfg.c +++ b/net/caif/cfcnfg.c @@ -499,6 +499,7 @@ got_phyid: cfserl_create(CFPHYTYPE_FRAG, phyid, stx); if (!phy_driver) { pr_warn("Out of memory\n"); + kfree(phyinfo); goto out; } break; @@ -506,6 +507,7 @@ got_phyid: phy_driver = NULL; break; default: + kfree(phyinfo); goto out; } phy_layer->id = phyid;