From: Jesper Juhl Date: Fri, 3 Aug 2007 23:25:26 +0000 (+0200) Subject: UBI: don't use array index before testing if it is negative X-Git-Tag: v2.6.24-rc1~1324^2^2~7 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0169b49d52400a6035cd0f2ccd08bcba061a1a9b;p=pandora-kernel.git UBI: don't use array index before testing if it is negative I can't find anything guaranteeing that 'ubi_num' cannot be <0 in drivers/mtd/ubi/kapi.c::ubi_open_volume(), and in fact the code even tests for that and errors out if so. Unfortunately the test for "ubi_num < 0" happens after we've already used 'ubi_num' as an array index - bad thing to do if it is negative. This patch moves the test earlier in the function and then moves the indexing using that variable after the check. A bit safer :-) Signed-off-by: Jesper Juhl Signed-off-by: Artem Bityutskiy --- Reading git-diff-tree failed