Thread (7 messages) 7 messages, 3 authors, 2009-07-31

Re: [PATCH 5/5] sound/aoa: Add kmalloc NULL tests

From: Julia Lawall <hidden>
Date: 2009-07-30 14:29:57
Also in: alsa-devel, kernel-janitors, lkml

On Thu, 30 Jul 2009, Johannes Berg wrote:
On Thu, 2009-07-30 at 16:11 +0200, Julia Lawall wrote:
quoted
From: Julia Lawall <redacted>

Check that the result of kzalloc is not NULL before a dereference.
quoted
 		irq_client = kzalloc(sizeof(struct pmf_irq_client),
 				     GFP_KERNEL);
+		if (!irq_client) {
+			err = -ENOMEM;
+			printk(KERN_ERR "snd-aoa: gpio layer failed to"
+				" register %s irq (%d)\n", name, err);
+			goto out_unlock;
+		}
Looks good, thanks, but I'd really drop the printk if only to not have
the string there, that doesn't really seem interesting.
The printk is based on similar error handling code a few lines later:

               if (err) {
                        printk(KERN_ERR "snd-aoa: gpio layer failed to"
                                        " register %s irq (%d)\n", name, 
err);
                        kfree(irq_client);
                        goto out_unlock;
                }

Should the printk be removed in this case as well?  Or is it ok to fail 
silently in one case and not in the other?

julia
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help