Commit e5141fc9 authored by David Woodhouse's avatar David Woodhouse

MTD: Fix oops after erase in NFTL/INFTL (DiskOnChip translation layers)

Fix kernel NULL pointer dereference at mtd_erase_callback+6 when trying
to insmod INFTL or NFTL modules.
Signed-off-by: default avatarKalev Lember <kalev@colleduc.ee>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent ad0a4dd6
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Author: Fabrice Bellard (fabrice.bellard@netgem.com) * Author: Fabrice Bellard (fabrice.bellard@netgem.com)
* Copyright (C) 2000 Netgem S.A. * Copyright (C) 2000 Netgem S.A.
* *
* $Id: inftlmount.c,v 1.14 2004/08/09 13:57:42 dwmw2 Exp $ * $Id: inftlmount.c,v 1.15 2004/11/05 21:55:55 kalev Exp $
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include <linux/mtd/inftl.h> #include <linux/mtd/inftl.h>
#include <linux/mtd/compatmac.h> #include <linux/mtd/compatmac.h>
char inftlmountrev[]="$Revision: 1.14 $"; char inftlmountrev[]="$Revision: 1.15 $";
/* /*
* find_boot_record: Find the INFTL Media Header and its Spare copy which * find_boot_record: Find the INFTL Media Header and its Spare copy which
...@@ -222,6 +222,8 @@ static int find_boot_record(struct INFTLrecord *inftl) ...@@ -222,6 +222,8 @@ static int find_boot_record(struct INFTLrecord *inftl)
if (ip->Reserved0 != ip->firstUnit) { if (ip->Reserved0 != ip->firstUnit) {
struct erase_info *instr = &inftl->instr; struct erase_info *instr = &inftl->instr;
instr->mtd = inftl->mbd.mtd;
/* /*
* Most likely this is using the * Most likely this is using the
* undocumented qiuck mount feature. * undocumented qiuck mount feature.
...@@ -387,6 +389,8 @@ int INFTL_formatblock(struct INFTLrecord *inftl, int block) ...@@ -387,6 +389,8 @@ int INFTL_formatblock(struct INFTLrecord *inftl, int block)
struct erase_info *instr = &inftl->instr; struct erase_info *instr = &inftl->instr;
int physblock; int physblock;
instr->mtd = inftl->mbd.mtd;
DEBUG(MTD_DEBUG_LEVEL3, "INFTL: INFTL_formatblock(inftl=%p," DEBUG(MTD_DEBUG_LEVEL3, "INFTL: INFTL_formatblock(inftl=%p,"
"block=%d)\n", inftl, block); "block=%d)\n", inftl, block);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Author: Fabrice Bellard (fabrice.bellard@netgem.com) * Author: Fabrice Bellard (fabrice.bellard@netgem.com)
* Copyright (C) 2000 Netgem S.A. * Copyright (C) 2000 Netgem S.A.
* *
* $Id: nftlmount.c,v 1.38 2004/10/20 23:20:26 dwmw2 Exp $ * $Id: nftlmount.c,v 1.39 2004/11/05 22:51:41 kalev Exp $
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#define SECTORSIZE 512 #define SECTORSIZE 512
char nftlmountrev[]="$Revision: 1.38 $"; char nftlmountrev[]="$Revision: 1.39 $";
/* find_boot_record: Find the NFTL Media Header and its Spare copy which contains the /* find_boot_record: Find the NFTL Media Header and its Spare copy which contains the
* various device information of the NFTL partition and Bad Unit Table. Update * various device information of the NFTL partition and Bad Unit Table. Update
...@@ -302,6 +302,8 @@ int NFTL_formatblock(struct NFTLrecord *nftl, int block) ...@@ -302,6 +302,8 @@ int NFTL_formatblock(struct NFTLrecord *nftl, int block)
struct nftl_uci1 uci; struct nftl_uci1 uci;
struct erase_info *instr = &nftl->instr; struct erase_info *instr = &nftl->instr;
instr->mtd = nftl->mbd.mtd;
/* Read the Unit Control Information #1 for Wear-Leveling */ /* Read the Unit Control Information #1 for Wear-Leveling */
if (MTD_READOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8, if (MTD_READOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8,
8, &retlen, (char *)&uci) < 0) 8, &retlen, (char *)&uci) < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment