Skip to contentSkip to conversation

nand: Fix set_dev checks for no device

PATCH New Tony Lindgren 2 participants 7 messages Aug 23, 2016 – Aug 24, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nand: Fix set_dev checks for no device

If we do nand device 0 command in u-boot on a device that has NAND support enabled but no NAND chip, we can get data abort at least on omaps.

Fix the issue by adding a check for nand_info[dev].

cmd/nand.c +1 -1
@@ -116,7 +116,7 @@ free_dat:
 static int set_dev(int dev)
 {
 	if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE ||
-	    !nand_info[dev]->name) {
+	    !nand_info[dev] || !nand_info[dev]->name) {
 		puts("No such device\n");
 		return -1;
 	}
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/1 nand: Fix set_dev checks for no device

Quoted 14 lines · Tony Lindgren

If we do nand device 0 command in u-boot on a device that has NAND support enabled but no NAND chip, we can get data abort at least on omaps.

Fix the issue by adding a check for nand_info[dev].

cmd/nand.c +0 -0
@@ -116,7 +116,7 @@ free_dat:
 ?static int set_dev(int dev)
 ?{

? if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE ||

cmd/nand.c +1 -1
-	????!nand_info[dev]->name) {
+	????!nand_info[dev] || !nand_info[dev]->name) {
Quoted 3 lines

? puts("No such device\n");
? return -1;
? }

The new !nand_info[dev] check can replace the old name check (similarly to how commit?4cc9699be7ffc replaced the old zero-blocksize check).

-Scott

#2 lore raw

PATCH 1/1 nand: Fix set_dev checks for no device

Quoted 6 lines · Scott Wood
Quoted 5 lines · Tony Lindgren

If we do nand device 0 command in u-boot on a device that has NAND support enabled but no NAND chip, we can get data abort at least on omaps.

Fix the issue by adding a check for nand_info[dev].

Quoted 15 lines
Quoted 9 lines
cmd/nand.c +0 -0
@@ -116,7 +116,7 @@ free_dat:
 ?static int set_dev(int dev)
 ?{

? if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE ||

cmd/nand.c +1 -1
-	????!nand_info[dev]->name) {
+	????!nand_info[dev] || !nand_info[dev]->name) {
Quoted 3 lines

? puts("No such device\n");
? return -1;
? }

The new !nand_info[dev] check can replace the old name check (similarly to how commit?4cc9699be7ffc replaced the old zero-blocksize check).

Do you mean we can now leave out the test for !nand_info[dev]->name in set_dev() with this patch?

Regards,

Tony

#3 lore raw

PATCH 1/1 nand: Fix set_dev checks for no device

Quoted 25 lines · Tony Lindgren
Quoted 9 lines · Scott Wood
Quoted 7 lines · Tony Lindgren

If we do nand device 0 command in u-boot on a device that has NAND support
enabled but no NAND chip, we can get data abort at least on omaps.

Fix the issue by adding a check for nand_info[dev].

Quoted 15 lines
Quoted 9 lines
cmd/nand.c +0 -0
@@ -116,7 +116,7 @@ free_dat:
 ?static int set_dev(int dev)
 ?{

? if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE ||

cmd/nand.c +1 -1
-	????!nand_info[dev]->name) {
+	????!nand_info[dev] || !nand_info[dev]->name) {
Quoted 3 lines

? puts("No such device\n");
? return -1;
? }

The new !nand_info[dev] check can replace the old name check (similarly to how
commit?4cc9699be7ffc replaced the old zero-blocksize check).

Quoted 2 lines

Do you mean we can now leave out the test for !nand_info[dev]->name in set_dev() with this patch?

Yes. ?It existed before because before the array-to-pointer conversion there was no way to directly test nand_info[dev] for emptiness.

-Scott

#4 lore raw

PATCH 1/1 nand: Fix set_dev checks for no device

Quoted 26 lines · Scott Wood
Quoted 25 lines · Tony Lindgren
Quoted 24 lines · Scott Wood
Quoted 16 lines · Tony Lindgren

If we do nand device 0 command in u-boot on a device that has NAND support
enabled but no NAND chip, we can get data abort at least on omaps.

Fix the issue by adding a check for nand_info[dev].

cmd/nand.c +0 -0
@@ -116,7 +116,7 @@ free_dat:
 ?static int set_dev(int dev)
 ?{

? if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE ||

cmd/nand.c +1 -1
-	????!nand_info[dev]->name) {
+	????!nand_info[dev] || !nand_info[dev]->name) {
Quoted 3 lines

? puts("No such device\n");
? return -1;
? }

The new !nand_info[dev] check can replace the old name check (similarly to how
commit?4cc9699be7ffc replaced the old zero-blocksize check).

Quoted 5 lines
Quoted 2 lines

Do you mean we can now leave out the test for !nand_info[dev]->name in set_dev() with this patch?

Yes. ?It existed before because before the array-to-pointer conversion there was no way to directly test nand_info[dev] for emptiness.

OK seems to work. Updated patch below.

Regards,

Tony
8< -----------------
From: Tony Lindgren <[email protected]>
Date: Tue, 23 Aug 2016 15:14:26 -0700
Subject: [PATCHv2] nand: Fix set_dev checks for no device

If we do nand device 0 command in u-boot on a device that has NAND support enabled but no NAND chip, we can get data abort at least on omaps.

Fix the issue by replaceing the check with nand_info[dev] as suggested by Scott Wood. The check for name existed before because before the array-to-pointer conversion there was no way to directly test nand_info[dev] for emptiness.

cmd/nand.c +1 -2
@@ -115,8 +115,7 @@ free_dat:
 
 static int set_dev(int dev)
 {
-	if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE ||
-	    !nand_info[dev]->name) {
+	if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[dev]) {
 		puts("No such device\n");
 		return -1;
 	}
#5 lore raw

PATCH 1/1 nand: Fix set_dev checks for no device

Quoted 9 lines · Tony Lindgren

OK seems to work. Updated patch below.

Regards,

Tony
8< -----------------
From: Tony Lindgren <[email protected]>
Date: Tue, 23 Aug 2016 15:14:26 -0700
Subject: [PATCHv2] nand: Fix set_dev checks for no device

Could you please send a standalone patch (no 8< ------) generated by git, or at least that has the "diff" line? ?These aren't even showing up in patchwork as is.

Quoted 5 lines

If we do nand device 0 command in u-boot on a device that has NAND support enabled but no NAND chip, we can get data abort at least on omaps.

Fix the issue by replaceing the check with nand_info[dev] as suggested by Scott Wood.

"replacing the name check with..."

-Scott

#6 lore raw

PATCH 1/1 nand: Fix set_dev checks for no device

Quoted 11 lines · Scott Wood
Quoted 9 lines · Tony Lindgren

OK seems to work. Updated patch below.

Regards,

Tony
8< -----------------
From: Tony Lindgren <[email protected]>
Date: Tue, 23 Aug 2016 15:14:26 -0700
Subject: [PATCHv2] nand: Fix set_dev checks for no device

Quoted 3 lines

Could you please send a standalone patch (no 8< ------) generated by git, or at least that has the "diff" line? ?These aren't even showing up in patchwork as is.

Oh OK sure.

Quoted 7 lines
Quoted 5 lines

If we do nand device 0 command in u-boot on a device that has NAND support enabled but no NAND chip, we can get data abort at least on omaps.

Fix the issue by replaceing the check with nand_info[dev] as suggested by Scott Wood.

"replacing the name check with..."

Thanks for spotting that, just sent v3 of the patch.

Tony