From patchwork Tue Aug 7 18:16:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Juhl X-Patchwork-Id: 1287541 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id EFA00DF280 for ; Tue, 7 Aug 2012 18:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756055Ab2HGSQ5 (ORCPT ); Tue, 7 Aug 2012 14:16:57 -0400 Received: from 1010ds2-suoe.0.fullrate.dk ([90.184.90.115]:10847 "EHLO swampdragon.chaosbits.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753016Ab2HGSQ5 (ORCPT ); Tue, 7 Aug 2012 14:16:57 -0400 Received: by swampdragon.chaosbits.net (Postfix, from userid 1000) id B1A2E9403D; Tue, 7 Aug 2012 20:16:55 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by swampdragon.chaosbits.net (Postfix) with ESMTP id AFBB29403B; Tue, 7 Aug 2012 20:16:55 +0200 (CEST) Date: Tue, 7 Aug 2012 20:16:55 +0200 (CEST) From: Jesper Juhl To: Dmitry Torokhov cc: Sourav Poddar , Felipe Balbi , JJ Ding , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Abraham Arce , Syed Rafiuddin Subject: [PATCH] Input: omap4-keypad - don't leak in omap4_keypad_probe() Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org If omap4_keypad_parse_dt() does not return 0 (zero) in omap4_keypad_probe() we will leak the memory we allocated for 'keypad_data' with kzalloc() when we return and the variable goes out of scope. Fix the leak by jumping to the 'err_free_keypad' label where we properly free the allocated memory, instead of returning directly. Signed-off-by: Jesper Juhl --- drivers/input/keyboard/omap4-keypad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Compile tested only. diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index c05f98c..9c2ac87 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -281,7 +281,7 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev) } else { error = omap4_keypad_parse_dt(&pdev->dev, keypad_data); if (error) - return error; + goto err_free_keypad; } res = request_mem_region(res->start, resource_size(res), pdev->name);