diff mbox

[U-Boot] image-fdt: boot_get_fdt() return value when no DTB exists

Message ID 1413987469-26139-1-git-send-email-noamc@ezchip.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Noam Camus Oct. 22, 2014, 2:17 p.m. UTC
From: Noam Camus <noamc@ezchip.com>

I believe that when no DTB is around we should return 1.
This why I fixed such scenarious to not return zero anymore.
Else kernel might get NULL pointer to DTB which doesn't exists.

Signed-off-by: Noam Camus <noamc@ezchip.com>
---
 common/image-fdt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Tom Rini Oct. 22, 2014, 4:48 p.m. UTC | #1
On Wed, Oct 22, 2014 at 05:17:49PM +0300, Noam Camus wrote:

> From: Noam Camus <noamc@ezchip.com>
> 
> I believe that when no DTB is around we should return 1.
> This why I fixed such scenarious to not return zero anymore.
> Else kernel might get NULL pointer to DTB which doesn't exists.
> 
> Signed-off-by: Noam Camus <noamc@ezchip.com>

While this is probably OK and not an issue, my only "what if" is, what
about for appened device trees?
Alexey Brodkin Oct. 22, 2014, 5:15 p.m. UTC | #2
Hi Tom,

On Wed, 2014-10-22 at 12:48 -0400, Tom Rini wrote:
> On Wed, Oct 22, 2014 at 05:17:49PM +0300, Noam Camus wrote:
> 
> > From: Noam Camus <noamc@ezchip.com>
> > 
> > I believe that when no DTB is around we should return 1.
> > This why I fixed such scenarious to not return zero anymore.
> > Else kernel might get NULL pointer to DTB which doesn't exists.
> > 
> > Signed-off-by: Noam Camus <noamc@ezchip.com>
> 
> While this is probably OK and not an issue, my only "what if" is, what
> about for appened device trees?

Which device tree do you mean?
The one built in uImage or in FIT image?

-Alexey
Tom Rini Oct. 22, 2014, 5:33 p.m. UTC | #3
On Wed, Oct 22, 2014 at 05:15:07PM +0000, Alexey Brodkin wrote:
> Hi Tom,
> 
> On Wed, 2014-10-22 at 12:48 -0400, Tom Rini wrote:
> > On Wed, Oct 22, 2014 at 05:17:49PM +0300, Noam Camus wrote:
> > 
> > > From: Noam Camus <noamc@ezchip.com>
> > > 
> > > I believe that when no DTB is around we should return 1.
> > > This why I fixed such scenarious to not return zero anymore.
> > > Else kernel might get NULL pointer to DTB which doesn't exists.
> > > 
> > > Signed-off-by: Noam Camus <noamc@ezchip.com>
> > 
> > While this is probably OK and not an issue, my only "what if" is, what
> > about for appened device trees?
> 
> Which device tree do you mean?
> The one built in uImage or in FIT image?

I'm talking about the allowed-by-kludgey case of a device tree being
cat'd to the end of an image prior to loading.
Tom Rini Nov. 10, 2014, 9:26 p.m. UTC | #4
On Wed, Oct 22, 2014 at 05:17:49PM +0300, Noam Camus wrote:

> From: Noam Camus <noamc@ezchip.com>
> 
> I believe that when no DTB is around we should return 1.
> This why I fixed such scenarious to not return zero anymore.
> Else kernel might get NULL pointer to DTB which doesn't exists.
> 
> Signed-off-by: Noam Camus <noamc@ezchip.com>

Applied to u-boot/master, thanks!
Tom Rini Dec. 3, 2014, 6:21 p.m. UTC | #5
On Wed, Oct 22, 2014 at 05:17:49PM +0300, Noam Camus wrote:

> From: Noam Camus <noamc@ezchip.com>
> 
> I believe that when no DTB is around we should return 1.
> This why I fixed such scenarious to not return zero anymore.
> Else kernel might get NULL pointer to DTB which doesn't exists.
> 
> Signed-off-by: Noam Camus <noamc@ezchip.com>

It has been found that this change breaks the case of an appended device
tree file, so for the problem in question some other solution must be
found.

This reverts commit c6150aaf2f2745141a7c2ceded58d7efbfeace7d.

Reported-by: Bill Pringlemeir <bpringlemeir@nbsps.com>
Reported-by: Pantelis Antoniou <panto@antoniou-consulting.com>
Confirmed-by: Bill Pringlemeir <bpringlemeir@nbsps.com>
Signed-off-by: Tom Rini <trini@ti.com>
diff mbox

Patch

diff --git a/common/image-fdt.c b/common/image-fdt.c
index 9fc7481..c142ae6 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -413,11 +413,11 @@  int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
 			}
 		} else {
 			debug("## No Flattened Device Tree\n");
-			return 0;
+			goto error;
 		}
 	} else {
 		debug("## No Flattened Device Tree\n");
-		return 0;
+		goto error;
 	}
 
 	*of_flat_tree = fdt_blob;