[MTD] Fix error checking after get_mtd_device() in get_sb_mtd functions

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Jun 1 14:59:02 EDT 2007


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=718ea8361b15aec5f4cb559d63ba34bc5a58d8f9
Commit:     718ea8361b15aec5f4cb559d63ba34bc5a58d8f9
Parent:     ea55d30798ac206c9f584ac264b6b8eb093d237a
Author:     David Woodhouse <dwmw2 at infradead.org>
AuthorDate: Fri Jun 1 19:21:59 2007 +0100
Committer:  David Woodhouse <dwmw2 at infradead.org>
CommitDate: Fri Jun 1 19:21:59 2007 +0100

    [MTD] Fix error checking after get_mtd_device() in get_sb_mtd functions
    
    It returns ERR_PTR(foo) on error, not just NULL.
    
    Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
 drivers/mtd/mtdsuper.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c
index a279540..aca3319 100644
--- a/drivers/mtd/mtdsuper.c
+++ b/drivers/mtd/mtdsuper.c
@@ -106,9 +106,9 @@ static int get_sb_mtd_nr(struct file_system_type *fs_type, int flags,
 	struct mtd_info *mtd;
 
 	mtd = get_mtd_device(NULL, mtdnr);
-	if (!mtd) {
+	if (IS_ERR(mtd)) {
 		DEBUG(0, "MTDSB: Device #%u doesn't appear to exist\n", mtdnr);
-		return -EINVAL;
+		return PTR_ERR(mtd);
 	}
 
 	return get_sb_mtd_aux(fs_type, flags, dev_name, data, mtd, fill_super,
@@ -145,7 +145,7 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
 
 			for (mtdnr = 0; mtdnr < MAX_MTD_DEVICES; mtdnr++) {
 				mtd = get_mtd_device(NULL, mtdnr);
-				if (mtd) {
+				if (!IS_ERR(mtd)) {
 					if (!strcmp(mtd->name, dev_name + 4))
 						return get_sb_mtd_aux(
 							fs_type, flags,



More information about the linux-mtd-cvs mailing list