From patchwork Mon Nov 7 14:01:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 124078 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9A7231007D4 for ; Tue, 8 Nov 2011 01:02:25 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932501Ab1KGOCJ (ORCPT ); Mon, 7 Nov 2011 09:02:09 -0500 Received: from mail-iy0-f174.google.com ([209.85.210.174]:48780 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755578Ab1KGOCI (ORCPT ); Mon, 7 Nov 2011 09:02:08 -0500 Received: by iage36 with SMTP id e36so5867422iag.19 for ; Mon, 07 Nov 2011 06:02:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=9fOvfzQsDiRZ5hiLUS//E9LtfErmHythgvk4J2yyqs4=; b=s9vYo186PuikHKfP0eTl6LY5oFux8I17vLUwD5xTUoxAvQjb6j6qsUFMS1QTo7jEwD V3wFMk+GWnOVah+469EKqZbemmsxJjJiMUTtqjwHqZYz0R3tfsKxThINCbbAaNYCaVzP 5acrCnAtxC1sS4qUQZfi7PiFq2GxRQ7w7/+XY= Received: by 10.231.84.8 with SMTP id h8mr11387040ibl.47.1320674528042; Mon, 07 Nov 2011 06:02:08 -0800 (PST) Received: from localhost.localdomain ([59.16.241.227]) by mx.google.com with ESMTPS id lt8sm36653355pbb.0.2011.11.07.06.02.05 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 07 Nov 2011 06:02:07 -0800 (PST) From: Namjae Jeon To: tytso@mit.edu Cc: linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, Namjae Jeon Subject: [PATCH v2] ext4: fix NULL pointer dereference from orig_data in fill_super and remount. Date: Mon, 7 Nov 2011 23:01:51 +0900 Message-Id: <1320674511-1980-1-git-send-email-linkinjeon@gmail.com> X-Mailer: git-send-email 1.7.4.4 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Fix NULL pointer dereference from orig_data in fill_super and remount. Signed-off-by: Namjae Jeon Reviewed-by: Srivatsa S. Bhat --- fs/ext4/super.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 9953d80..717b3e8 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -3102,7 +3102,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) __releases(kernel_lock) __acquires(kernel_lock) { - char *orig_data = kstrdup(data, GFP_KERNEL); struct buffer_head *bh; struct ext4_super_block *es = NULL; struct ext4_sb_info *sbi; @@ -3125,6 +3124,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO; ext4_group_t first_not_zeroed; + char *orig_data = kstrdup(data, GFP_KERNEL); + if (!orig_data) + return ret; + sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) goto out_free_orig; @@ -4398,6 +4401,8 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) int i; #endif char *orig_data = kstrdup(data, GFP_KERNEL); + if (!orig_data) + return -ENOMEM; /* Store the original options */ lock_super(sb);