From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752290AbZGaGcJ (ORCPT ); Fri, 31 Jul 2009 02:32:09 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751800AbZGaGcI (ORCPT ); Fri, 31 Jul 2009 02:32:08 -0400 Received: from mgw2.diku.dk ([130.225.96.92]:60867 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751811AbZGaGcH (ORCPT ); Fri, 31 Jul 2009 02:32:07 -0400 Date: Fri, 31 Jul 2009 08:32:03 +0200 (CEST) From: Julia Lawall To: Takashi Iwai Cc: Johannes Berg , linuxppc-dev@ozlabs.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH 5/5] sound/aoa: Add kmalloc NULL tests In-Reply-To: Message-ID: References: <1248963420.16129.0.camel@johannes.local> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julia Lawall Check that the result of kzalloc is not NULL before a dereference. The semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ expression *x; identifier f; constant char *C; @@ x = \(kmalloc\|kcalloc\|kzalloc\)(...); ... when != x == NULL when != x != NULL when != (x || ...) ( kfree(x) | f(...,C,...,x,...) | *f(...,x,...) | *x->f ) // Signed-off-by: Julia Lawall --- sound/aoa/core/gpio-pmf.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/var/linuxes/linux-next/sound/aoa/core/gpio-pmf.c b/var/julia/linuxcopy/sound/aoa/core/gpio-pmf.c index 5ca2220..1dd0c28 100644 --- a/var/linuxes/linux-next/sound/aoa/core/gpio-pmf.c +++ b/var/julia/linuxcopy/sound/aoa/core/gpio-pmf.c @@ -182,6 +182,10 @@ static int pmf_set_notify(struct gpio_runtime *rt, if (!old && notify) { irq_client = kzalloc(sizeof(struct pmf_irq_client), GFP_KERNEL); + if (!irq_client) { + err = -ENOMEM; + goto out_unlock; + } irq_client->data = notif; irq_client->handler = pmf_handle_notify_irq; irq_client->owner = THIS_MODULE;