[PATCH v2] mtd-utils: ubinfo: add parameter check

Aaron Marcher me at drkhsh.at
Tue Aug 8 03:53:27 PDT 2017


Adds a check if the UBI device number is specified when passing a volume
name as parameter.

This fixes an issue, where by default an inexistent UBI device named
"ubi-1" is selected because of missing checks.

Signed-off-by: Aaron Marcher <me at drkhsh.at>
---
 ubi-utils/ubinfo.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ubi-utils/ubinfo.c b/ubi-utils/ubinfo.c
index 82d4f18..29530be 100644
--- a/ubi-utils/ubinfo.c
+++ b/ubi-utils/ubinfo.c
@@ -399,6 +399,12 @@ int main(int argc, char * const argv[])
 			goto out_libubi;
 	}
 
+	if (args.vol_name && args.devn == -1) {
+		errmsg("volume name is specified, but UBI device number is not "
+			   "(use -h for help)\n");
+		goto out_libubi;
+	}
+
 	if (args.vol_name) {
 		err = get_vol_id_by_name(libubi, args.devn, args.vol_name);
 		if (err)
-- 
2.14.0





More information about the linux-mtd mailing list