summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorChen Gang <gang.chen@asianux.com>2013-05-21 17:20:50 +0800
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-07-01 11:46:56 +1000
commit7029705a9d0544186c29ae09708b3e5adb512835 (patch)
tree5156e8edaa013c77b3fd007ab83ddff873d9d622 /arch
parentcce606feb425093c8371089d392e336d186e125b (diff)
downloadlinux-7029705a9d0544186c29ae09708b3e5adb512835.tar.gz
linux-7029705a9d0544186c29ae09708b3e5adb512835.tar.bz2
linux-7029705a9d0544186c29ae09708b3e5adb512835.zip
powerpc/nvram64: Need return the related error code on failure occurs
When error occurs, need return the related error code to let upper caller know about it. ppc_md.nvram_size() can return the error code (e.g. core99_nvram_size() in 'arch/powerpc/platforms/powermac/nvram.c'). Also set ret value when only need it, so can save structions for normal cases. Signed-off-by: Chen Gang <gang.chen@asianux.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/kernel/nvram_64.c20
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,
char *tmp = NULL;
ssize_t size;
- ret = -ENODEV;
- if (!ppc_md.nvram_size)
+ if (!ppc_md.nvram_size) {
+ ret = -ENODEV;
goto out;
+ }
- ret = 0;
size = ppc_md.nvram_size();
- if (*ppos >= size || size < 0)
+ if (size < 0) {
+ ret = size;
+ goto out;
+ }
+
+ if (*ppos >= size) {
+ ret = 0;
goto out;
+ }
count = min_t(size_t, count, size - *ppos);
count = min(count, PAGE_SIZE);
- ret = -ENOMEM;
tmp = kmalloc(count, GFP_KERNEL);
- if (!tmp)
+ if (!tmp) {
+ ret = -ENOMEM;
goto out;
+ }
ret = ppc_md.nvram_read(tmp, count, ppos);
if (ret <= 0)