MIPS: VPE: Free relocation chain on error.

This may happen if a bad sequence of relocations is being encountered.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

+12 -3
+12 -3
arch/mips/kernel/vpe.c
··· 462 { 463 unsigned long insnlo = *location; 464 Elf32_Addr val, vallo; 465 466 /* Sign extend the addend we extract from the lo insn. */ 467 vallo = ((insnlo & 0xffff) ^ 0x8000) - 0x8000; 468 469 if (mips_hi16_list != NULL) { 470 - struct mips_hi16 *l; 471 472 l = mips_hi16_list; 473 while (l != NULL) { 474 - struct mips_hi16 *next; 475 unsigned long insn; 476 477 /* ··· 480 printk(KERN_DEBUG "VPE loader: " 481 "apply_r_mips_lo16/hi16: \t" 482 "inconsistent value information\n"); 483 - return -ENOEXEC; 484 } 485 486 /* ··· 518 *location = insnlo; 519 520 return 0; 521 } 522 523 static int (*reloc_handlers[]) (struct module *me, uint32_t *location,
··· 462 { 463 unsigned long insnlo = *location; 464 Elf32_Addr val, vallo; 465 + struct mips_hi16 *l, *next; 466 467 /* Sign extend the addend we extract from the lo insn. */ 468 vallo = ((insnlo & 0xffff) ^ 0x8000) - 0x8000; 469 470 if (mips_hi16_list != NULL) { 471 472 l = mips_hi16_list; 473 while (l != NULL) { 474 unsigned long insn; 475 476 /* ··· 481 printk(KERN_DEBUG "VPE loader: " 482 "apply_r_mips_lo16/hi16: \t" 483 "inconsistent value information\n"); 484 + goto out_free; 485 } 486 487 /* ··· 519 *location = insnlo; 520 521 return 0; 522 + 523 + out_free: 524 + while (l != NULL) { 525 + next = l->next; 526 + kfree(l); 527 + l = next; 528 + } 529 + mips_hi16_list = NULL; 530 + 531 + return -ENOEXEC; 532 } 533 534 static int (*reloc_handlers[]) (struct module *me, uint32_t *location,