sparc: fix warning on prom_getproperty in openprom.c
PATCH 1/1 sparc: fix warning on prom_getproperty in openprom.c
This patch resolves the following build warnings seen in 2.6.17-rc3:drivers/sbus/char/openprom.c:395: warning: ignoring return value of `prom_getproperty', declared with attribute warn_unused_result
Please apply.
Martin
---
drivers/sbus/char/openprom.c renamed from drivers/sbus/char/openprom.c.orig +4 -3
@@ -392,12 +392,13 @@return -ENOMEM ; } -prom_getproperty (op.op_nodeid, str, tmp, len); + error =prom_getproperty (op.op_nodeid, str, tmp, len); tmp[len] ='\0' ; -if (__copy_to_user (argp, &op,sizeof (op)) !=0 - ||copy_to_user (op.op_buf, tmp, len) !=0 ) +if ((error <=0 ) || +__copy_to_user (argp, &op,sizeof (op)) !=0 || +copy_to_user (op.op_buf, tmp, len) !=0 ) error = -EFAULT ;kfree (tmp);
David S. Miller
maintainerFrom: Martin Habets <[email protected]>
Date: Sun, 7 May 2006 16:24:50 +0100
Quoted 7 lines
This patch resolves the following build warnings seen in 2.6.17-rc3:
drivers/sbus/char/openprom.c:395: warning: ignoring return value of `prom_getproperty', declared with attributewarn_unused_resultPlease apply.
MartinSigned-off-by Martin Habets <[email protected]>
The intention is correct but if we get an error from prom_getproperty() then -EFAULT is not likely the appropiate thing to return. Perhaps -EINVAL or something like that.
Quoted 6 lines · David S. Miller
From: Martin Habets <[email protected]>
Date: Sun, 7 May 2006 16:24:50 +0100Quoted 3 lines
This patch resolves the following build warnings seen in 2.6.17-rc3:
drivers/sbus/char/openprom.c:395: warning: ignoring return value of `prom_getproperty', declared with attributewarn_unused_result
Quoted 8 lines
Quoted 4 lines
Please apply.
MartinSigned-off-by Martin Habets <[email protected]>The intention is correct but if we get an error from
prom_getproperty()then-EFAULTis not likely the appropiate thing to return. Perhaps-EINVALor something like that.
Seems like a hypothetical case to me, since the code just did a prom_getproplen() a few lines before. It makes the patch a bit bigger.
Signature · 29 lines
Martin Signed-off-by: Martin Habets <[email protected]> --- 2.6.17-rc3/drivers/sbus/char/openprom.c.orig 2006-05-06 18:48:44.000000000 +0100 +++ 2.6.17-rc3/drivers/sbus/char/openprom.c 2006-05-09 21:52:14.000000000 +0100 @@ -392,13 +392,16 @@ return -ENOMEM; } - prom_getproperty(op.op_nodeid, str, tmp, len); - - tmp[len] = '\0'; + cnt = prom_getproperty(op.op_nodeid, str, tmp, len); + if (cnt <= 0) { + error = -EINVAL; + } else { + tmp[len] = '\0'; - if (__copy_to_user(argp, &op, sizeof(op)) != 0 - || copy_to_user(op.op_buf, tmp, len) != 0) - error = -EFAULT; + if (__copy_to_user(argp, &op, sizeof(op)) != 0 || + copy_to_user(op.op_buf, tmp, len) != 0) + error = -EFAULT; + } kfree(tmp); kfree(str);
From: Martin Habets <[email protected]>
Date: Tue, 9 May 2006 22:05:26 +0100
Quoted 2 lines
Seems like a hypothetical case to me, since the code just did a
prom_getproplen()a few lines before. It makes the patch a bit bigger.
Better to do it correctly though :-)
Quoted 1 line
Signed-off-by Martin Habets <[email protected]>
Applied, thanks a lot.