From patchwork Sun Sep 2 14:23:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 1396721 X-Patchwork-Delegate: deller@gmx.de Return-Path: X-Original-To: patchwork-linux-parisc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id D0AD63FC71 for ; Sun, 2 Sep 2012 14:24:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753618Ab2IBOYA (ORCPT ); Sun, 2 Sep 2012 10:24:00 -0400 Received: from mail-qa0-f46.google.com ([209.85.216.46]:61160 "EHLO mail-qa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753502Ab2IBOX7 (ORCPT ); Sun, 2 Sep 2012 10:23:59 -0400 Received: by qaas11 with SMTP id s11so1821519qaa.19 for ; Sun, 02 Sep 2012 07:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=KefXC6YFGim3LOYq/pGC4XzWx8fsZfYYoDpS55/TOzE=; b=mNWq8oZJFG3i/m7Ann7mqLBZ323ApjAtg14Wq1W+cv2a4sYtmtDUoHLwjhK62LXQCz 1TzRJcPxM2RRv8ahe/Qf9Tpw/Maw32ukOc2cnTIDrzfT8mZ0AYpXVk61XHqpQK9vxuJb OXPBenlNHVrUf+dfjbYqRdjAhqvI+IS1DFngPtMZT907mY34rlM4zuLIRC8W//q6uXo9 qa3w29ObeAa/VZXDOs/Yq8nmNAA3/lKiUbaIFgXKAJqeFbPuXMXdVe3tNRZ4DTKHFhiu Xr1D4JASRqR98ENiQ3Fn4uP+KiQfeUTPySSQyO77wDqvZcSNgTmEQWN4WMk/39x4pUPy my5w== MIME-Version: 1.0 Received: by 10.224.196.132 with SMTP id eg4mr29650839qab.93.1346595839039; Sun, 02 Sep 2012 07:23:59 -0700 (PDT) Received: by 10.229.146.194 with HTTP; Sun, 2 Sep 2012 07:23:59 -0700 (PDT) Date: Sun, 2 Sep 2012 22:23:59 +0800 Message-ID: Subject: [PATCH] parisc: fix possible memory leak in pat_query_module() From: Wei Yongjun To: jejb@parisc-linux.org, deller@gmx.de Cc: yongjun_wei@trendmicro.com.cn, linux-parisc@vger.kernel.org Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org From: Wei Yongjun pa_pdc_cell has been allocated in this function and so should be freed before leaving from the error handling cases. spatch with a semantic match is used to found this problem. (http://coccinelle.lip6.fr/) Signed-off-by: Wei Yongjun --- arch/parisc/kernel/inventory.c | 2 ++ 1 file changed, 2 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/parisc/kernel/inventory.c b/arch/parisc/kernel/inventory.c index 08324aa..3295ef4 100644 --- a/arch/parisc/kernel/inventory.c +++ b/arch/parisc/kernel/inventory.c @@ -186,12 +186,14 @@ pat_query_module(ulong pcell_loc, ulong mod_index) if (status != PDC_OK) { /* no more cell modules or error */ + kfree(pa_pdc_cell); return status; } temp = pa_pdc_cell->cba; dev = alloc_pa_dev(PAT_GET_CBA(temp), &(pa_pdc_cell->mod_path)); if (!dev) { + kfree(pa_pdc_cell); return PDC_OK; }