lkml.org 
[lkml]   [2008]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] hfs: if match_strdup() fails to allocate memory in parse_options(), don't blow up the kernel.
From
Date
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.



\
 
 \ /
  Last update: 2008-04-22 23:21    [W:0.029 / U:0.280 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site