From: Jesper Juhl Date: Mon, 6 Feb 2012 09:07:04 +0000 (+1100) Subject: mpi: Avoid using freed pointer in mpi_lshift_limbs() X-Git-Tag: v3.4-rc4~30^2~1 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09c79b60960bdd4b00916219402eabfa5e479c5a;p=pandora-kernel.git mpi: Avoid using freed pointer in mpi_lshift_limbs() At the start of the function we assign 'a->d' to 'ap'. Then we use the RESIZE_IF_NEEDED macro on 'a' - this may free 'a->d' and replace it with newly allocaetd storage. In that case, we'll be operating on freed memory further down in the function when we index into 'ap[]'. Since we don't actually need 'ap' until after the use of the RESIZE_IF_NEEDED macro we can just delay the assignment to it until after we've potentially resized, thus avoiding the issue. While I was there anyway I also changed the integer variable 'n' to be const. It might as well be since we only assign to it once and use it as a constant, and then the compiler will tell us if we ever assign to it in the future. Signed-off-by: Jesper Juhl Acked-by: Dmitry Kasatkin Signed-off-by: James Morris --- Reading git-diff-tree failed