* [U-Boot] [PATCH] nand: Fix set_dev checks for no device
@ 2016-08-23 21:26 Tony Lindgren
2016-08-23 21:30 ` Scott Wood
0 siblings, 1 reply; 7+ messages in thread
From: Tony Lindgren @ 2016-08-23 21:26 UTC (permalink / raw)
To: u-boot
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].
Signed-off-by: Tony Lindgren <tony@atomide.com>
--- a/cmd/nand.c
+++ b/cmd/nand.c
@@ -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;
}
--
2.9.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] nand: Fix set_dev checks for no device
2016-08-23 21:26 [U-Boot] [PATCH] nand: Fix set_dev checks for no device Tony Lindgren
@ 2016-08-23 21:30 ` Scott Wood
2016-08-23 22:04 ` Tony Lindgren
0 siblings, 1 reply; 7+ messages in thread
From: Scott Wood @ 2016-08-23 21:30 UTC (permalink / raw)
To: u-boot
On Tue, 2016-08-23 at 14:26 -0700, Tony Lindgren wrote:
> 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].
>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> --- a/cmd/nand.c
> +++ b/cmd/nand.c
> @@ -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;
> ? }
The new !nand_info[dev] check can replace the old name check (similarly to how
commit?4cc9699be7ffc replaced the old zero-blocksize check).
-Scott
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] nand: Fix set_dev checks for no device
2016-08-23 21:30 ` Scott Wood
@ 2016-08-23 22:04 ` Tony Lindgren
2016-08-23 22:07 ` Scott Wood
0 siblings, 1 reply; 7+ messages in thread
From: Tony Lindgren @ 2016-08-23 22:04 UTC (permalink / raw)
To: u-boot
* Scott Wood <oss@buserror.net> [160823 14:31]:
> On Tue, 2016-08-23 at 14:26 -0700, Tony Lindgren wrote:
> > 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].
> >
> > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > --- a/cmd/nand.c
> > +++ b/cmd/nand.c
> > @@ -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;
> > ? }
>
> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] nand: Fix set_dev checks for no device
2016-08-23 22:04 ` Tony Lindgren
@ 2016-08-23 22:07 ` Scott Wood
2016-08-23 22:21 ` Tony Lindgren
0 siblings, 1 reply; 7+ messages in thread
From: Scott Wood @ 2016-08-23 22:07 UTC (permalink / raw)
To: u-boot
On Tue, 2016-08-23 at 15:04 -0700, Tony Lindgren wrote:
> * Scott Wood <oss@buserror.net> [160823 14:31]:
> >
> > On Tue, 2016-08-23 at 14:26 -0700, Tony Lindgren wrote:
> > >
> > > 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].
> > >
> > > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > > --- a/cmd/nand.c
> > > +++ b/cmd/nand.c
> > > @@ -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;
> > > ? }
> > 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?
Yes. ?It existed before because before the array-to-pointer conversion there
was no way to directly test nand_info[dev] for emptiness.
-Scott
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] nand: Fix set_dev checks for no device
2016-08-23 22:07 ` Scott Wood
@ 2016-08-23 22:21 ` Tony Lindgren
2016-08-24 0:04 ` Scott Wood
0 siblings, 1 reply; 7+ messages in thread
From: Tony Lindgren @ 2016-08-23 22:21 UTC (permalink / raw)
To: u-boot
* Scott Wood <oss@buserror.net> [160823 15:08]:
> On Tue, 2016-08-23 at 15:04 -0700, Tony Lindgren wrote:
> > * Scott Wood <oss@buserror.net> [160823 14:31]:
> > >
> > > On Tue, 2016-08-23 at 14:26 -0700, Tony Lindgren wrote:
> > > >
> > > > 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].
> > > >
> > > > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > > > --- a/cmd/nand.c
> > > > +++ b/cmd/nand.c
> > > > @@ -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;
> > > > ? }
> > > 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?
>
> 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 <tony@atomide.com>
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.
Signed-off-by: Tony Lindgren <tony@atomide.com>
--- a/cmd/nand.c
+++ b/cmd/nand.c
@@ -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;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] nand: Fix set_dev checks for no device
2016-08-23 22:21 ` Tony Lindgren
@ 2016-08-24 0:04 ` Scott Wood
2016-08-24 16:47 ` Tony Lindgren
0 siblings, 1 reply; 7+ messages in thread
From: Scott Wood @ 2016-08-24 0:04 UTC (permalink / raw)
To: u-boot
On Tue, 2016-08-23 at 15:21 -0700, Tony Lindgren wrote:
> OK seems to work. Updated patch below.
>
> Regards,
>
> Tony
> 8< -----------------
> From: Tony Lindgren <tony@atomide.com>
> 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.
> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH] nand: Fix set_dev checks for no device
2016-08-24 0:04 ` Scott Wood
@ 2016-08-24 16:47 ` Tony Lindgren
0 siblings, 0 replies; 7+ messages in thread
From: Tony Lindgren @ 2016-08-24 16:47 UTC (permalink / raw)
To: u-boot
* Scott Wood <oss@buserror.net> [160823 17:05]:
> On Tue, 2016-08-23 at 15:21 -0700, Tony Lindgren wrote:
> > OK seems to work. Updated patch below.
> >
> > Regards,
> >
> > Tony
> > 8< -----------------
> > From: Tony Lindgren <tony@atomide.com>
> > 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.
Oh OK sure.
> > 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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-08-24 16:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-23 21:26 [U-Boot] [PATCH] nand: Fix set_dev checks for no device Tony Lindgren
2016-08-23 21:30 ` Scott Wood
2016-08-23 22:04 ` Tony Lindgren
2016-08-23 22:07 ` Scott Wood
2016-08-23 22:21 ` Tony Lindgren
2016-08-24 0:04 ` Scott Wood
2016-08-24 16:47 ` Tony Lindgren
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.