From: Dan Carpenter <dan.carpenter@oracle.com>
To: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org,
Manohar Vanga <manohar.vanga@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Igor Alekseev <igor.alekseev@itep.ru>,
Martyn Welch <martyn.welch@ge.com>,
"Hans J. Koch" <hjk@hansjkoch.de>
Subject: Re: [RFC] Generic VME UIO
Date: Thu, 23 Jul 2015 10:29:31 +0300 [thread overview]
Message-ID: <20150723072930.GP5371@mwanda> (raw)
In-Reply-To: <1437588546-1855-1-git-send-email-dmitry.kalinkin@gmail.com>
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
next prev parent reply other threads:[~2015-07-23 7:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-22 18:09 [RFC] Generic VME UIO Dmitry Kalinkin
2015-07-23 7:29 ` Dan Carpenter [this message]
2015-07-28 17:03 ` Martyn Welch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150723072930.GP5371@mwanda \
--to=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=dmitry.kalinkin@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hjk@hansjkoch.de \
--cc=igor.alekseev@itep.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=manohar.vanga@gmail.com \
--cc=martyn.welch@ge.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox