Skip to content

Commit

Permalink
MTD: Fix wrong check register_blkdev return value
Browse files Browse the repository at this point in the history
register_blkdev return 1..255 when major = 0.

if (ret ) {
	printk(KERN_WARNING "Unable to register %s block device on major %d: %d\n",
		tr->name, tr->major, ret);
	      mutex_unlock(&mtd_table_mutex);
	return ret;
}

Above code will return fail when register_blkdev return allocated major number.

Signed-off-by: Frank Li <Frank.Li@freescale.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
Frank Li authored and David Woodhouse committed Oct 30, 2010
1 parent 6411bf6 commit 6fe4c59
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/mtd/mtd_blkdevs.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,13 +502,16 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
mutex_lock(&mtd_table_mutex);

ret = register_blkdev(tr->major, tr->name);
if (ret) {
if (ret < 0) {
printk(KERN_WARNING "Unable to register %s block device on major %d: %d\n",
tr->name, tr->major, ret);
mutex_unlock(&mtd_table_mutex);
return ret;
}

if (ret)
tr->major = ret;

tr->blkshift = ffs(tr->blksize) - 1;

INIT_LIST_HEAD(&tr->devs);
Expand Down

0 comments on commit 6fe4c59

Please sign in to comment.