]> git.proxmox.com Git - qemu.git/blobdiff - loader.c
Don't leak VLANClientState on PCI hot remove
[qemu.git] / loader.c
index cf603cc09909b52fc0fb030c60f19534b263764a..23bb03982ad1dd30995b3bac4df606604ec571d4 100644 (file)
--- a/loader.c
+++ b/loader.c
@@ -90,11 +90,12 @@ int fread_targphys(target_phys_addr_t dst_addr, size_t nbytes, FILE *f)
     while (nbytes) {
        want = nbytes > sizeof(buf) ? sizeof(buf) : nbytes;
        did = fread(buf, 1, want, f);
-       if (did != want) break;
 
        cpu_physical_memory_write_rom(dst_addr, buf, did);
        dst_addr += did;
        nbytes -= did;
+       if (did != want)
+           break;
     }
     return dst_addr - dst_begin;
 }
@@ -266,8 +267,6 @@ static void *load_at(int fd, int offset, int size)
     if (lseek(fd, offset, SEEK_SET) < 0)
         return NULL;
     ptr = qemu_malloc(size);
-    if (!ptr)
-        return NULL;
     if (read(fd, ptr, size) != size) {
         qemu_free(ptr);
         return NULL;
@@ -384,7 +383,7 @@ static void *zalloc(void *x, unsigned items, unsigned size)
     return (p);
 }
 
-static void zfree(void *x, void *addr, unsigned nb)
+static void zfree(void *x, void *addr)
 {
     qemu_free(addr);
 }
@@ -432,7 +431,7 @@ static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src,
     }
 
     s.zalloc = zalloc;
-    s.zfree = (free_func)zfree;
+    s.zfree = zfree;
 
     r = inflateInit2(&s, -MAX_WBITS);
     if (r != Z_OK) {
@@ -505,8 +504,6 @@ int load_uimage(const char *filename, target_ulong *ep, target_ulong *loadaddr,
 
     *ep = hdr->ih_ep;
     data = qemu_malloc(hdr->ih_size);
-    if (!data)
-        goto out;
 
     if (read(fd, data, hdr->ih_size) != hdr->ih_size) {
         fprintf(stderr, "Error reading file\n");