diff mbox

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

Message ID 20170808105327.11905-1-me@drkhsh.at
State Accepted
Delegated to: David Oberhollenzer
Headers show

Commit Message

Aaron Marcher Aug. 8, 2017, 10:53 a.m. UTC
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@drkhsh.at>
---
 ubi-utils/ubinfo.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

David Oberhollenzer Aug. 10, 2017, 9:55 a.m. UTC | #1
Applied to mtd-utils.git

Thanks,

David
diff mbox

Patch

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)