Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unchecked return value in fdt_add_subnode_namelen() #46

Closed
longr96 opened this issue Feb 24, 2021 · 1 comment
Closed

Unchecked return value in fdt_add_subnode_namelen() #46

longr96 opened this issue Feb 24, 2021 · 1 comment

Comments

@longr96
Copy link

longr96 commented Feb 24, 2021

RTEMS (RTEMS.org) is a free single process, multi-threaded real-time operating system with a long history. Your dtc toolchain has been incorporated into RTEMS. The RTEMS Project is a member of the Coverity Scan program and it flagged an issue with /dtc/libfdt/fdt_rw.c. In trying to be good citizens of the wider open source community, the project wants these issues to be reported to the upstream owner along with a fix or suggestions. This is one of those reports.

When Coverity Scan was ran on some of your code, a "Unchecked return value" error was found at line 352 in fdt_rw.c. For similar errors that we received for RTEMS, we created a macro that will assert the value returned and "use" the return value like so.

int status = fdt_next_tag(fdt, parentoffset, &nextoffset);
assert(status == 0);
(void)status;

You can just use the "(void)fdt_next_tag()" if you don't care to check the return value of the functional call at all, but this is just a suggestion.

@dgibson
Copy link
Owner

dgibson commented Mar 9, 2021

We can't use assert() in libfdt, because we it needs to be usable in very constrained environments (like bootloaders) which might not have an assert() (or if they do it might not work like the libc one). Our rough equivalent to assert()s is to return FDT_ERR_INTERNAL.

I'm not sure why our own Coverity didn't pick this one up, but in any case I've made what should be a fix in a somewhat different way.

@dgibson dgibson closed this as completed Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants