* [PATCH] PowerPC: kernel: need return the related error code when failure occurs.
@ 2013-05-21 5:48 Chen Gang
2013-05-21 8:10 ` Paul Mackerras
0 siblings, 1 reply; 11+ messages in thread
From: Chen Gang @ 2013-05-21 5:48 UTC (permalink / raw)
To: Arnd Bergmann, Benjamin Herrenschmidt, paulus, zhangyanfei,
Jiri Kosina, Michael Ellerman
Cc: linuxppc-dev, linux-kernel
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').
And when '*ppos >= size', need return -ESPIPE (Illegal seek)
The original related patch: "f9ce299 [PATCH] powerpc: fix large nvram
access"
Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
arch/powerpc/kernel/nvram_64.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 48fbc2b..db2a636 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -88,10 +88,15 @@ static ssize_t dev_nvram_read(struct file *file, char __user *buf,
if (!ppc_md.nvram_size)
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 = -ESPIPE;
+ goto out;
+ }
count = min_t(size_t, count, size - *ppos);
count = min(count, PAGE_SIZE);
--
1.7.7.6
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] PowerPC: kernel: need return the related error code when failure occurs.
2013-05-21 5:48 [PATCH] PowerPC: kernel: need return the related error code when failure occurs Chen Gang
@ 2013-05-21 8:10 ` Paul Mackerras
0 siblings, 0 replies; 11+ messages in thread
From: Paul Mackerras @ 2013-05-21 8:10 UTC (permalink / raw)
To: Chen Gang
Cc: Arnd Bergmann, Benjamin Herrenschmidt, zhangyanfei, Jiri Kosina,
Michael Ellerman, linuxppc-dev, linux-kernel
On Tue, May 21, 2013 at 01:48:58PM +0800, Chen Gang wrote:
>
> 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').
>
> And when '*ppos >= size', need return -ESPIPE (Illegal seek)
Why? When *ppos >= size, it should return 0 (end of file) in my opinion.
ESPIPE means that any seek would be ineffective, not that a particular
seek went out of bounds.
Paul.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] PowerPC: kernel: need return the related error code when failure occurs.
@ 2013-05-21 8:10 ` Paul Mackerras
0 siblings, 0 replies; 11+ messages in thread
From: Paul Mackerras @ 2013-05-21 8:10 UTC (permalink / raw)
To: Chen Gang
Cc: Arnd Bergmann, linux-kernel, zhangyanfei, Jiri Kosina, linuxppc-dev
On Tue, May 21, 2013 at 01:48:58PM +0800, Chen Gang wrote:
>
> 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').
>
> And when '*ppos >= size', need return -ESPIPE (Illegal seek)
Why? When *ppos >= size, it should return 0 (end of file) in my opinion.
ESPIPE means that any seek would be ineffective, not that a particular
seek went out of bounds.
Paul.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] PowerPC: kernel: need return the related error code when failure occurs.
2013-05-21 8:10 ` Paul Mackerras
@ 2013-05-21 9:03 ` Chen Gang
-1 siblings, 0 replies; 11+ messages in thread
From: Chen Gang @ 2013-05-21 9:03 UTC (permalink / raw)
To: Paul Mackerras
Cc: Arnd Bergmann, Benjamin Herrenschmidt, zhangyanfei, Jiri Kosina,
Michael Ellerman, linuxppc-dev, linux-kernel
On 05/21/2013 04:10 PM, Paul Mackerras wrote:
> On Tue, May 21, 2013 at 01:48:58PM +0800, Chen Gang wrote:
>> >
>> > 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').
>> >
>> > And when '*ppos >= size', need return -ESPIPE (Illegal seek)
> Why? When *ppos >= size, it should return 0 (end of file) in my opinion.
> ESPIPE means that any seek would be ineffective, not that a particular
> seek went out of bounds.
OK, thanks, I will send patch v2. :-)
Thanks.
--
Chen Gang
Asianux Corporation
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] PowerPC: kernel: need return the related error code when failure occurs.
@ 2013-05-21 9:03 ` Chen Gang
0 siblings, 0 replies; 11+ messages in thread
From: Chen Gang @ 2013-05-21 9:03 UTC (permalink / raw)
To: Paul Mackerras
Cc: Arnd Bergmann, linux-kernel, zhangyanfei, Jiri Kosina, linuxppc-dev
On 05/21/2013 04:10 PM, Paul Mackerras wrote:
> On Tue, May 21, 2013 at 01:48:58PM +0800, Chen Gang wrote:
>> >
>> > 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').
>> >
>> > And when '*ppos >= size', need return -ESPIPE (Illegal seek)
> Why? When *ppos >= size, it should return 0 (end of file) in my opinion.
> ESPIPE means that any seek would be ineffective, not that a particular
> seek went out of bounds.
OK, thanks, I will send patch v2. :-)
Thanks.
--
Chen Gang
Asianux Corporation
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2] PowerPC: kernel: need return the related error code when failure occurs
2013-05-21 9:03 ` Chen Gang
@ 2013-05-21 9:20 ` Chen Gang
-1 siblings, 0 replies; 11+ messages in thread
From: Chen Gang @ 2013-05-21 9:20 UTC (permalink / raw)
To: Paul Mackerras
Cc: Arnd Bergmann, Benjamin Herrenschmidt, zhangyanfei, Jiri Kosina,
Michael Ellerman, linuxppc-dev, linux-kernel
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.
The original related patch: "f9ce299 [PATCH] powerpc: fix large nvram
access".
Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
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 48fbc2b..8213ee1 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)
--
1.7.7.6
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2] PowerPC: kernel: need return the related error code when failure occurs
@ 2013-05-21 9:20 ` Chen Gang
0 siblings, 0 replies; 11+ messages in thread
From: Chen Gang @ 2013-05-21 9:20 UTC (permalink / raw)
To: Paul Mackerras
Cc: Arnd Bergmann, linux-kernel, zhangyanfei, Jiri Kosina, linuxppc-dev
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.
The original related patch: "f9ce299 [PATCH] powerpc: fix large nvram
access".
Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
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 48fbc2b..8213ee1 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)
--
1.7.7.6
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2] PowerPC: kernel: need return the related error code when failure occurs
2013-05-21 9:20 ` Chen Gang
@ 2013-05-27 10:01 ` Chen Gang
-1 siblings, 0 replies; 11+ messages in thread
From: Chen Gang @ 2013-05-27 10:01 UTC (permalink / raw)
To: Paul Mackerras
Cc: Arnd Bergmann, Benjamin Herrenschmidt, zhangyanfei, Jiri Kosina,
Michael Ellerman, linuxppc-dev, linux-kernel, Linux-Arch
Hello Maintainers:
Please help check this patch whether is OK, when you have time.
Thanks.
On 05/21/2013 05:20 PM, Chen Gang wrote:
>
> 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.
>
> The original related patch: "f9ce299 [PATCH] powerpc: fix large nvram
> access".
>
>
> Signed-off-by: Chen Gang <gang.chen@asianux.com>
> ---
> 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 48fbc2b..8213ee1 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)
>
--
Chen Gang
Asianux Corporation
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] PowerPC: kernel: need return the related error code when failure occurs
@ 2013-05-27 10:01 ` Chen Gang
0 siblings, 0 replies; 11+ messages in thread
From: Chen Gang @ 2013-05-27 10:01 UTC (permalink / raw)
To: Paul Mackerras
Cc: Linux-Arch, Arnd Bergmann, linux-kernel, zhangyanfei,
Jiri Kosina, linuxppc-dev
Hello Maintainers:
Please help check this patch whether is OK, when you have time.
Thanks.
On 05/21/2013 05:20 PM, Chen Gang wrote:
>
> 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.
>
> The original related patch: "f9ce299 [PATCH] powerpc: fix large nvram
> access".
>
>
> Signed-off-by: Chen Gang <gang.chen@asianux.com>
> ---
> 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 48fbc2b..8213ee1 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)
>
--
Chen Gang
Asianux Corporation
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] PowerPC: kernel: need return the related error code when failure occurs
@ 2013-06-22 4:08 ` Chen Gang
0 siblings, 0 replies; 11+ messages in thread
From: Chen Gang @ 2013-06-22 4:08 UTC (permalink / raw)
To: paulus, Michael Ellerman, Benjamin Herrenschmidt
Cc: Arnd Bergmann, zhangyanfei, Jiri Kosina, linuxppc-dev,
linux-kernel, Linux-Arch
Hello Maintainers:
Please help check this patch whether is OK, when you have time.
Thanks.
On 05/21/2013 05:20 PM, Chen Gang wrote:
>
> 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.
>
> The original related patch: "f9ce299 [PATCH] powerpc: fix large nvram
> access".
>
>
> Signed-off-by: Chen Gang <gang.chen@asianux.com>
> ---
> 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 48fbc2b..8213ee1 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)
>
Thanks
--
Chen Gang
Asianux Corporation
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] PowerPC: kernel: need return the related error code when failure occurs
@ 2013-06-22 4:08 ` Chen Gang
0 siblings, 0 replies; 11+ messages in thread
From: Chen Gang @ 2013-06-22 4:08 UTC (permalink / raw)
To: paulus, Michael Ellerman, Benjamin Herrenschmidt
Cc: Linux-Arch, Arnd Bergmann, Jiri Kosina, linux-kernel,
zhangyanfei, linuxppc-dev
Hello Maintainers:
Please help check this patch whether is OK, when you have time.
Thanks.
On 05/21/2013 05:20 PM, Chen Gang wrote:
>
> 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.
>
> The original related patch: "f9ce299 [PATCH] powerpc: fix large nvram
> access".
>
>
> Signed-off-by: Chen Gang <gang.chen@asianux.com>
> ---
> 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 48fbc2b..8213ee1 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)
>
Thanks
--
Chen Gang
Asianux Corporation
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2013-06-22 4:09 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-21 5:48 [PATCH] PowerPC: kernel: need return the related error code when failure occurs Chen Gang
2013-05-21 8:10 ` Paul Mackerras
2013-05-21 8:10 ` Paul Mackerras
2013-05-21 9:03 ` Chen Gang
2013-05-21 9:03 ` Chen Gang
2013-05-21 9:20 ` [PATCH v2] " Chen Gang
2013-05-21 9:20 ` Chen Gang
2013-05-27 10:01 ` Chen Gang
2013-05-27 10:01 ` Chen Gang
2013-06-22 4:08 Chen Gang
2013-06-22 4:08 ` Chen Gang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.