[PATCH -mm] UBI: one less BUG usage
Randy Dunlap
randy.dunlap at oracle.com
Tue Jun 26 18:30:27 EDT 2007
From: Randy Dunlap <randy.dunlap at oracle.com>
Eliminate one BUG() usage. The callers of major_to_device() already
handle and report errors. This is just another error to return.
Signed-off-by: Randy Dunlap <randy.dunlap at oracle.com>
---
drivers/mtd/ubi/cdev.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- linux-2622-rc4mm2.orig/drivers/mtd/ubi/cdev.c
+++ linux-2622-rc4mm2/drivers/mtd/ubi/cdev.c
@@ -63,7 +63,7 @@ static struct ubi_device *major_to_devic
for (i = 0; i < ubi_devices_cnt; i++)
if (ubi_devices[i] && ubi_devices[i]->major == major)
return ubi_devices[i];
- BUG();
+ return ERR_PTR(-ENODEV);
}
/**
@@ -127,6 +127,9 @@ static int vol_cdev_open(struct inode *i
int vol_id = iminor(inode) - 1;
int mode;
+ if (IS_ERR(ubi))
+ return PTR_ERR(ubi);
+
if (file->f_mode & FMODE_WRITE)
mode = UBI_READWRITE;
else
More information about the linux-mtd
mailing list