* [PATCH] Fix error-code overwrite bug
@ 2015-01-04 18:04 Giel van Schijndel
2015-01-04 23:03 ` Giel van Schijndel
2015-01-07 18:37 ` Andy Shevchenko
0 siblings, 2 replies; 5+ messages in thread
From: Giel van Schijndel @ 2015-01-04 18:04 UTC (permalink / raw)
To: linux-kernel
Cc: Giel van Schijndel, David Woodhouse, Brian Norris,
open list:MEMORY TECHNOLOGY...
Don't overwrite the returned error code with the boolean test used by
the if-statement (otherwise it'd be 1 or 0 always, 1 in the if-block).
---
drivers/mtd/nftlmount.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
index 51b9d6a..1cbeb6b 100644
--- a/drivers/mtd/nftlmount.c
+++ b/drivers/mtd/nftlmount.c
@@ -91,7 +91,7 @@ static int find_boot_record(struct NFTLrecord *nftl)
/* To be safer with BIOS, also use erase mark as discriminant */
if ((ret = nftl_read_oob(mtd, block * nftl->EraseSize +
SECTORSIZE + 8, 8, &retlen,
- (char *)&h1) < 0)) {
+ (char *)&h1)) < 0) {
printk(KERN_WARNING "ANAND header found at 0x%x in mtd%d, but OOB data read failed (err %d)\n",
block * nftl->EraseSize, nftl->mbd.mtd->index, ret);
continue;
--
2.1.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix error-code overwrite bug
2015-01-04 18:04 [PATCH] Fix error-code overwrite bug Giel van Schijndel
@ 2015-01-04 23:03 ` Giel van Schijndel
2015-01-07 18:37 ` Andy Shevchenko
1 sibling, 0 replies; 5+ messages in thread
From: Giel van Schijndel @ 2015-01-04 23:03 UTC (permalink / raw)
To: linux-kernel
Cc: David Woodhouse, Brian Norris, open list:MEMORY TECHNOLOGY...
[-- Attachment #1: Type: text/plain, Size: 500 bytes --]
On Sun, Jan 04, 2015 at 19:04:22 +0100, Giel van Schijndel wrote:
> Don't overwrite the returned error code with the boolean test used by
> the if-statement (otherwise it'd be 1 or 0 always, 1 in the if-block).
> ---
Forgot to:
Signed-off-by: Giel van Schijndel <me@mortis.eu>
--
Met vriendelijke groet,
With kind regards,
Giel van Schijndel
--
"If debugging is the process of removing software bugs, then programming
must be the process of putting them in."
-- Edsger Dijkstra
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix error-code overwrite bug
2015-01-04 18:04 [PATCH] Fix error-code overwrite bug Giel van Schijndel
2015-01-04 23:03 ` Giel van Schijndel
@ 2015-01-07 18:37 ` Andy Shevchenko
2015-01-07 19:52 ` Giel van Schijndel
1 sibling, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2015-01-07 18:37 UTC (permalink / raw)
To: Giel van Schijndel
Cc: linux-kernel, David Woodhouse, Brian Norris,
open list:MEMORY TECHNOLOGY...
On Sun, Jan 4, 2015 at 8:04 PM, Giel van Schijndel <me@mortis.eu> wrote:
> Don't overwrite the returned error code with the boolean test used by
> the if-statement (otherwise it'd be 1 or 0 always, 1 in the if-block).
> ---
> drivers/mtd/nftlmount.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
> index 51b9d6a..1cbeb6b 100644
> --- a/drivers/mtd/nftlmount.c
> +++ b/drivers/mtd/nftlmount.c
> @@ -91,7 +91,7 @@ static int find_boot_record(struct NFTLrecord *nftl)
> /* To be safer with BIOS, also use erase mark as discriminant */
> if ((ret = nftl_read_oob(mtd, block * nftl->EraseSize +
> SECTORSIZE + 8, 8, &retlen,
> - (char *)&h1) < 0)) {
> + (char *)&h1)) < 0) {
Better to move ret = x(); outside of condition. See here:
http://permalink.gmane.org/gmane.linux.drivers.mtd/56922
P.S.If you are going to fix more, may you talk to me via some channel
like irc, jabber, etc?
> printk(KERN_WARNING "ANAND header found at 0x%x in mtd%d, but OOB data read failed (err %d)\n",
> block * nftl->EraseSize, nftl->mbd.mtd->index, ret);
> continue;
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix error-code overwrite bug
2015-01-07 18:37 ` Andy Shevchenko
@ 2015-01-07 19:52 ` Giel van Schijndel
2015-01-07 20:09 ` Andy Shevchenko
0 siblings, 1 reply; 5+ messages in thread
From: Giel van Schijndel @ 2015-01-07 19:52 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-kernel, David Woodhouse, Brian Norris,
open list:MEMORY TECHNOLOGY...
[-- Attachment #1: Type: text/plain, Size: 1912 bytes --]
On Wed, Jan 07, 2015 at 20:37:29 +0200, Andy Shevchenko wrote:
> On Sun, Jan 4, 2015 at 8:04 PM, Giel van Schijndel <me@mortis.eu> wrote:
>> Don't overwrite the returned error code with the boolean test used by
>> the if-statement (otherwise it'd be 1 or 0 always, 1 in the if-block).
>> ---
>> drivers/mtd/nftlmount.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
>> index 51b9d6a..1cbeb6b 100644
>> --- a/drivers/mtd/nftlmount.c
>> +++ b/drivers/mtd/nftlmount.c
>> @@ -91,7 +91,7 @@ static int find_boot_record(struct NFTLrecord *nftl)
>> /* To be safer with BIOS, also use erase mark as discriminant */
>> if ((ret = nftl_read_oob(mtd, block * nftl->EraseSize +
>> SECTORSIZE + 8, 8, &retlen,
>> - (char *)&h1) < 0)) {
>> + (char *)&h1)) < 0) {
>
> Better to move ret = x(); outside of condition. See here:
> http://permalink.gmane.org/gmane.linux.drivers.mtd/56922
In the sense that this bug wouldn't have occurred when using separate
assignment and condition checking you're right. It's a style issue
though, but a relevant one.
So your approach is probably better, though incomplete (like mine), just
look for the exact same (ret = x() < 0) pattern about 20 lines further
down the same file. (Yes that's disabled code, but I still believe the
bug should be fixed considering it's exactly the same class of bug).
So I suggest you resend that ^^ patch you link to with a fix for the
other instance of the bug fixed as well.
--
Met vriendelijke groet,
With kind regards,
Giel van Schijndel
--
"If debugging is the process of removing software bugs, then programming
must be the process of putting them in."
-- Edsger Dijkstra
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix error-code overwrite bug
2015-01-07 19:52 ` Giel van Schijndel
@ 2015-01-07 20:09 ` Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-01-07 20:09 UTC (permalink / raw)
To: Giel van Schijndel
Cc: linux-kernel, David Woodhouse, Brian Norris,
open list:MEMORY TECHNOLOGY...
On Wed, Jan 7, 2015 at 9:52 PM, Giel van Schijndel <me@mortis.eu> wrote:
> On Wed, Jan 07, 2015 at 20:37:29 +0200, Andy Shevchenko wrote:
>> On Sun, Jan 4, 2015 at 8:04 PM, Giel van Schijndel <me@mortis.eu> wrote:
>>> Don't overwrite the returned error code with the boolean test used by
>>> the if-statement (otherwise it'd be 1 or 0 always, 1 in the if-block).
>>> ---
>>> drivers/mtd/nftlmount.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
>>> index 51b9d6a..1cbeb6b 100644
>>> --- a/drivers/mtd/nftlmount.c
>>> +++ b/drivers/mtd/nftlmount.c
>>> @@ -91,7 +91,7 @@ static int find_boot_record(struct NFTLrecord *nftl)
>>> /* To be safer with BIOS, also use erase mark as discriminant */
>>> if ((ret = nftl_read_oob(mtd, block * nftl->EraseSize +
>>> SECTORSIZE + 8, 8, &retlen,
>>> - (char *)&h1) < 0)) {
>>> + (char *)&h1)) < 0) {
>>
>> Better to move ret = x(); outside of condition. See here:
>> http://permalink.gmane.org/gmane.linux.drivers.mtd/56922
>
> In the sense that this bug wouldn't have occurred when using separate
> assignment and condition checking you're right. It's a style issue
> though, but a relevant one.
>
> So your approach is probably better, though incomplete (like mine), just
> look for the exact same (ret = x() < 0) pattern about 20 lines further
> down the same file. (Yes that's disabled code, but I still believe the
> bug should be fixed considering it's exactly the same class of bug).
>
> So I suggest you resend that ^^ patch you link to with a fix for the
> other instance of the bug fixed as well.
Sounds reasonable. Will do.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-01-07 20:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-04 18:04 [PATCH] Fix error-code overwrite bug Giel van Schijndel
2015-01-04 23:03 ` Giel van Schijndel
2015-01-07 18:37 ` Andy Shevchenko
2015-01-07 19:52 ` Giel van Schijndel
2015-01-07 20:09 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®