[PATCH] UBI: Fix potential NULL-pointer dereference

Alexander Stein alexanders83 at web.de
Fri Mar 28 17:04:49 EDT 2014


It's no use to debug print a string before checking on NULL.

Signed-off-by: Alexander Stein <alexanders83 at web.de>
---
 drivers/mtd/ubi/kapi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index 3aac1ac..e40864f 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -242,11 +242,11 @@ struct ubi_volume_desc *ubi_open_volume_nm(int ubi_num, const char *name,
 	struct ubi_device *ubi;
 	struct ubi_volume_desc *ret;
 
-	dbg_gen("open device %d, volume %s, mode %d", ubi_num, name, mode);
-
 	if (!name)
 		return ERR_PTR(-EINVAL);
 
+	dbg_gen("open device %d, volume %s, mode %d", ubi_num, name, mode);
+
 	len = strnlen(name, UBI_VOL_NAME_MAX + 1);
 	if (len > UBI_VOL_NAME_MAX)
 		return ERR_PTR(-EINVAL);
-- 
1.9.1




More information about the linux-mtd mailing list