firmware: support loading into a pre-allocated buffer
[deliverable/linux.git] / fs / exec.c
index ca239fc86d8d0acd5446d754ff341e2d4d4613cb..a1789cd684bf25dde64739c2c38b1bcc23cd3eb3 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -866,7 +866,8 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size,
                goto out;
        }
 
-       *buf = vmalloc(i_size);
+       if (id != READING_FIRMWARE_PREALLOC_BUFFER)
+               *buf = vmalloc(i_size);
        if (!*buf) {
                ret = -ENOMEM;
                goto out;
@@ -897,8 +898,10 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size,
 
 out_free:
        if (ret < 0) {
-               vfree(*buf);
-               *buf = NULL;
+               if (id != READING_FIRMWARE_PREALLOC_BUFFER) {
+                       vfree(*buf);
+                       *buf = NULL;
+               }
        }
 
 out:
This page took 0.02398 seconds and 5 git commands to generate.