From: Joe Perches <joe@perches.com>
To: Jesper Juhl <jesper.juhl@gmail.com>
Cc: Roman Zippel <zippel@linux-m68k.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hfs: if match_strdup() fails to allocate memory in parse_options(), don't blow up the kernel.
Date: Tue, 22 Apr 2008 14:17:24 -0700 [thread overview]
Message-ID: <1208899044.8636.80.camel@localhost> (raw)
In-Reply-To: <alpine.LNX.1.00.0804222309250.14359@dragon.funnycrock.com>
On Tue, 2008-04-22 at 23:12 +0200, Jesper Juhl wrote:
> From: Jesper Juhl <jesper.juhl@gmail.com>
> diff --git a/fs/hfs/super.c b/fs/hfs/super.c
> index 32de44e..221e314 100644
> --- a/fs/hfs/super.c
> +++ b/fs/hfs/super.c
> @@ -297,6 +297,10 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
> return 0;
> }
> p = match_strdup(&args[0]);
> + if (!p) {
> + printk(KERN_ERR "hfs: mem alloc failed in match_strdup()\n");
> + return 0;
> + }
> hsb->nls_disk = load_nls(p);
> if (!hsb->nls_disk) {
> printk(KERN_ERR "hfs: unable to load codepage \"%s\"\n", p);
> @@ -311,6 +315,10 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
> return 0;
> }
> p = match_strdup(&args[0]);
> + if (!p) {
> + printk(KERN_ERR "hfs: memory allocation failed in match_strdup()\n");
> + return 0;
> + }
> hsb->nls_io = load_nls(p);
> if (!hsb->nls_io) {
> printk(KERN_ERR "hfs: unable to load iocharset \"%s\"\n", p);
>
Using different strings in the printk wastes memory.
next prev parent reply other threads:[~2008-04-22 21:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-22 21:12 Jesper Juhl
2008-04-22 21:17 ` Joe Perches [this message]
2008-04-22 21:21 ` Jesper Juhl
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=1208899044.8636.80.camel@localhost \
--to=joe@perches.com \
--cc=jesper.juhl@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=zippel@linux-m68k.org \
/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
all inboxes | Powered by JetHome®