diff options
-rw-r--r-- | arch/powerpc/kernel/nvram_64.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c index 48fbc2b97e95..8213ee1eb05a 100644 --- a/arch/powerpc/kernel/nvram_64.c +++ b/arch/powerpc/kernel/nvram_64.c | |||
@@ -84,22 +84,30 @@ static ssize_t dev_nvram_read(struct file *file, char __user *buf, | |||
84 | char *tmp = NULL; | 84 | char *tmp = NULL; |
85 | ssize_t size; | 85 | ssize_t size; |
86 | 86 | ||
87 | ret = -ENODEV; | 87 | if (!ppc_md.nvram_size) { |
88 | if (!ppc_md.nvram_size) | 88 | ret = -ENODEV; |
89 | goto out; | 89 | goto out; |
90 | } | ||
90 | 91 | ||
91 | ret = 0; | ||
92 | size = ppc_md.nvram_size(); | 92 | size = ppc_md.nvram_size(); |
93 | if (*ppos >= size || size < 0) | 93 | if (size < 0) { |
94 | ret = size; | ||
95 | goto out; | ||
96 | } | ||
97 | |||
98 | if (*ppos >= size) { | ||
99 | ret = 0; | ||
94 | goto out; | 100 | goto out; |
101 | } | ||
95 | 102 | ||
96 | count = min_t(size_t, count, size - *ppos); | 103 | count = min_t(size_t, count, size - *ppos); |
97 | count = min(count, PAGE_SIZE); | 104 | count = min(count, PAGE_SIZE); |
98 | 105 | ||
99 | ret = -ENOMEM; | ||
100 | tmp = kmalloc(count, GFP_KERNEL); | 106 | tmp = kmalloc(count, GFP_KERNEL); |
101 | if (!tmp) | 107 | if (!tmp) { |
108 | ret = -ENOMEM; | ||
102 | goto out; | 109 | goto out; |
110 | } | ||
103 | 111 | ||
104 | ret = ppc_md.nvram_read(tmp, count, ppos); | 112 | ret = ppc_md.nvram_read(tmp, count, ppos); |
105 | if (ret <= 0) | 113 | if (ret <= 0) |