Skip to contentSkip to conversation

UBI: return on error in rename_volumes()

PATCH Applied Dan Carpenter 2 participants 2 messages Sep 19, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 UBI: return on error in rename_volumes()

I noticed this during a code review. We are checking that the strlen() of ->name is not less than the ->name_len which the user gave us. I believe this bug is harmless but clearly we meant to return here instead of setting an error code and then not using it.

---
I'm not totally familiar with the code so please review extra carefully.

drivers/mtd/ubi/cdev.c +1 -1
index 20aeb27..59de69a 100644
@@ -701,7 +701,7 @@ static int rename_volumes(struct ubi_device *ubi,
 		req->ents[i].name[req->ents[i].name_len] = '\0';
 		n = strlen(req->ents[i].name);
 		if (n != req->ents[i].name_len)
-			err = -EINVAL;
+			return -EINVAL;
 	}
 
 	/* Make sure volume IDs and names are unique */
#1 lore raw
Quoted 4 lines · Dan Carpenter

I noticed this during a code review. We are checking that the strlen() of ->name is not less than the ->name_len which the user gave us. I believe this bug is harmless but clearly we meant to return here instead of setting an error code and then not using it.

Pushed to linux-ubifs.git, thanks!

Signature · 2 lines
Best Regards,
Artem Bityutskiy