Linux 6.1.32
[platform/kernel/linux-starfive.git] / scripts / recordmcount.c
index b9c2ee7..ec692af 100644 (file)
@@ -102,6 +102,7 @@ static ssize_t uwrite(void const *const buf, size_t const count)
 {
        size_t cnt = count;
        off_t idx = 0;
+       void *p = NULL;
 
        file_updated = 1;
 
@@ -109,7 +110,10 @@ static ssize_t uwrite(void const *const buf, size_t const count)
                off_t aoffset = (file_ptr + count) - file_end;
 
                if (aoffset > file_append_size) {
-                       file_append = realloc(file_append, aoffset);
+                       p = realloc(file_append, aoffset);
+                       if (!p)
+                               free(file_append);
+                       file_append = p;
                        file_append_size = aoffset;
                }
                if (!file_append) {
@@ -438,7 +442,7 @@ static int arm_is_fake_mcount(Elf32_Rel const *rp)
 
 static int arm64_is_fake_mcount(Elf64_Rel const *rp)
 {
-       return ELF64_R_TYPE(w(rp->r_info)) != R_AARCH64_CALL26;
+       return ELF64_R_TYPE(w8(rp->r_info)) != R_AARCH64_CALL26;
 }
 
 /* 64-bit EM_MIPS has weird ELF64_Rela.r_info.