Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752456AbbGWH35 (ORCPT ); Thu, 23 Jul 2015 03:29:57 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:33031 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752429AbbGWH3t (ORCPT ); Thu, 23 Jul 2015 03:29:49 -0400 Date: Thu, 23 Jul 2015 10:29:31 +0300 From: Dan Carpenter To: Dmitry Kalinkin Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, Manohar Vanga , Greg Kroah-Hartman , Igor Alekseev , Martyn Welch , "Hans J. Koch" Subject: Re: [RFC] Generic VME UIO Message-ID: <20150723072930.GP5371@mwanda> References: <1437588546-1855-1-git-send-email-dmitry.kalinkin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437588546-1855-1-git-send-email-dmitry.kalinkin@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1181 Lines: 36 On Wed, Jul 22, 2015 at 09:09:06PM +0300, Dmitry Kalinkin wrote: > + for (level = 1; level <= 7; level++) { > + char *level_node_name = kasprintf(GFP_KERNEL, "%d", level); > + struct kobject *level_node = kobject_create_and_add( > + level_node_name, kobj); > + if (!level_node) > + return -ENOMEM; >From the zero day testing results, what I've noticed is that allocations in the initializer are more error prone. You should be testing the results from kasprintf() and there is a leak if the "level_node" allocation fails. char *level_node_name; struct kobject *level_node; level_node_name = kasprintf(GFP_KERNEL, "%d", level); if (!level_node_name) return -ENOMEM; level_node = kobject_create_and_add(level_node_name, kobj); if (!level_node) { kfree(level_node_name); return -ENOMEM; } The other advantage to writing it like this is that you don't run into the 80 char limit. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/