Skip to content

Commit

Permalink
yaffs: repair yaffs_get_mtd_device
Browse files Browse the repository at this point in the history
The function yaffs_get_mtd_device use wrong function to retrieve
mtd_info structure (using yaffs_get_mtd_device itself will cause
dead loop).

Use get_mtd_device to do this.

Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
  • Loading branch information
wqyoung authored and zeddii committed Sep 26, 2023
1 parent f29838c commit 7086136
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions fs/yaffs2/yaffs_mtdif.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,17 +256,25 @@ struct mtd_info * yaffs_get_mtd_device(dev_t sdev)
{
struct mtd_info *mtd;

mtd = yaffs_get_mtd_device(sdev);

/* Check it's an mtd device..... */
if (MAJOR(sdev) != MTD_BLOCK_MAJOR)
return NULL; /* This isn't an mtd device */

/* Get the device */
mtd = get_mtd_device(NULL, MINOR(sdev));
if (IS_ERR_OR_NULL(mtd)) {
yaffs_trace(YAFFS_TRACE_ALWAYS,
"yaffs: MTD device %u either not valid or unavailable",
MINOR(sdev));
return NULL;
}

/* Check it's NAND */
if (mtd->type != MTD_NANDFLASH) {
yaffs_trace(YAFFS_TRACE_ALWAYS,
"yaffs: MTD device is not NAND it's type %d",
mtd->type);
put_mtd_device(mtd);
return NULL;
}

Expand Down

0 comments on commit 7086136

Please sign in to comment.