summaryrefslogtreecommitdiffstats
path: root/cpukit/dtc/libfdt/fdt_rw.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Fix CID 1461557David Gibson2021-12-141-5/+8
| | | | | | | | | | | | Coverity gets a bit confused by loading fdt_size_dt_strings() and using it in a memmove(). In fact this is safe because the callers have verified this information (via FDT_RW_PROBE() in fdt_pack() or construction in fdt_open_into()). Passing in strings_size like we already do struct_size seems to get Coverity to follow what's going on here. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Fix a possible "unchecked return value" warningDavid Gibson2021-12-141-1/+4
| | | | | | | | | | | | | | | | Apparently the unchecked return value of the first fdt_next_tag() call in fdt_add_subnode_namelen() is tripping Coverity Scan in some circumstances, although it appears not to for the scan on our project itself. This fdt_next_tag() should always return FDT_BEGIN_NODE, since otherwise the fdt_subnode_offset_namelen() above would have returned BADOFFSET or BADSTRUCTURE. Still, add a check to shut Coverity up, gated by a can_assume() to avoid bloat in small builds. Reported-by: Ryan Long <ryan.long@oarcorp.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Set last_comp_version correctly in new dtb and fix potential version issues ↵Justin Covell2021-12-141-1/+3
| | | | | | | | | | | | | | | in fdt_open_into Changes in v3: - Remove noop version sets - Set version correctly on loaded fdt in fdt_open_into Fixes: f1879e1a50eb ("Add limited read-only support for older (V2 and V3) device tree to libfdt.") Signed-off-by: Justin Covell <jujugoboom@gmail.com> Message-Id: <20201229041749.2187-1-jujugoboom@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: fdt_splice_(): Fix comparison warningAndre Przywara2021-12-141-1/+1
| | | | | | | | | | | | With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_splice_(). Since we just established that oldlen is not negative, we can safely cast it to an unsigned type. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20200921165303.9115-8-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Correct condition for reordering blocksSimon Glass2021-12-141-1/+1
| | | | | | | | | This condition uses bitwise OR but should be logical OR. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: kernel test robot <lkp@intel.com> Message-Id: <20200615160033.87328-1-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: fix undefined behaviour in fdt_splice_()Jan Beulich2021-12-141-6/+7
| | | | | | | | | | | | | | libfdt: fix undefined behaviour in fdt_splice_() Along the lines of commit d0b3ab0a0f46 ("libfdt: Fix undefined behaviour in fdt_offset_ptr()"), fdt_splice_() similarly may not use pointer arithmetic to do overflow checks. (The left side of the checks added by d4c7c25c9ed1 ["libfdt: check for potential overrun in _fdt_splice()"] doesn't really lend itself to similar replacement though.) Signed-off-by: Jan Beulich <jbeulich@suse.com> Message-Id: <f2d09e81-7cb8-c5cc-9699-1ac05b0626ff@suse.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Add support for disabling ordering check/fixupSimon Glass2020-03-021-1/+2
| | | | | | | | | | Add a way to remove this check and the reordering code, which is unnecessary if the dtb is known to be correctly ordered. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Message-Id: <20200220214557.176528-8-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Add support for disabling version checksSimon Glass2020-03-021-3/+3
| | | | | | | | | Allow enabling FDT_ASSUME_LATEST to disable version checks. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Message-Id: <20200220214557.176528-7-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Add support for disabling rollback handlingSimon Glass2020-03-021-3/+15
| | | | | | | | | | Allow enabling FDT_ASSUME_NO_ROLLBACK to disable rolling back after a failed operation. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Message-Id: <20200220214557.176528-6-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Add support for disabling dtb checksSimon Glass2020-03-021-0/+2
| | | | | | | | | | | Support ASSUME_VALID_DTB to disable some sanity checks If we assume that the DTB itself is valid then we can skip some checks and save code space. Add various conditions to handle this. Signed-off-by: Simon Glass <sjg@chromium.org> Message-Id: <20200220214557.176528-4-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Replace GPL/BSD boilerplate/reference with SPDX tagsRob Herring2020-03-021-46/+1
| | | | | | | | Replace instances of dual GPLv2 or BSD license boilerplate with SPDX tags. Signed-off-by: Rob Herring <robh@kernel.org> Message-Id: <20190620211944.9378-3-robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Ensure fdt_add_property frees allocated name string on failureNicholas Piggin2020-03-021-3/+19
| | | | | | | | | | | | | If fdt_add_property or fdt_property_placeholder fail after allocating a string for the name, they return without freeing that string. This does not change the structure of the tree, but in very specific cases it could lead to undesirable space consumption. Fix this by rolling back the string allocation in this situation. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Message-Id: <20190509094122.834-2-npiggin@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Clean up header checking functionsDavid Gibson2018-07-191-14/+14
| | | | | | | | | | | | | | | | | | | Many of the libfdt entry points call some sort of sanity check function before doing anything else. These need to do slightly different things for the various classes of functions. The read-only version is shared with the exported fdt_check_header(), which limits us a bit in how we can improve it. For that reason split the two functions apart (though the exported one just calls the ro one for now). We also rename the functions for more consistency - they're all named fdt_XX_probe_() where the XX indicates which class of functions they're for. "probe" is a better "term" than the previous check, since they really only do minimal validation. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
* libfdt: Remove leading underscores from identifiersDavid Gibson2018-07-191-45/+45
| | | | | | | | | | | | | | In a lot of places libfdt uses a leading _ character to mark an identifier as "internal" (not part of the published libfdt API). This is a bad idea, because identifiers with a leading _ are generally reserved by the C library or system. It's particularly dangerous for libfdt, because it's designed to be able to be integrated into lots of different environments. In some cases the leading _ has no purpose, so we simply drop it. In most cases we move it to the end, as our new convention for marking internal identifiers. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Introduce fdt_setprop_placeholder() methodPantelis Antoniou2018-07-191-3/+17
| | | | | | | | | | | | In some cases you need to add a property but the contents of it are not known at creation time, merely the extend of it. This method allows you to create a property of a given size (filled with garbage) while a pointer to the property data will be provided. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> [dwg: Corrected commit message] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Fix a few whitespace and style nitsSimon Glass2018-07-191-2/+2
| | | | | | | These were noticed when synching with U-Boot's downstream tree. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Remove undefined behaviour setting empty propertiesDavid Gibson2018-07-191-1/+2
| | | | | | | | | | | | | | The standard way of setting an empty property using libfdt is: fdt_setprop(fdt, nodeoffset, propname, NULL, 0); However, the implementation of this includes an unconditional: memcpy(prop->data, NULL, 0); Which although it will be a no-op (which is what we want) on many platforms is technically undefined behaviour. Correct this, so that when passing a 0 length, passing a NULL pointer as the value to fdt_setprop() is definitely safe. This should quiet static checkers which complain about this. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: simplify fdt_del_mem_rsv()Masahiro Yamada2018-07-191-5/+1
| | | | | | | The variable "err" is unneeded. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: check for potential overrun in _fdt_splice()Courtney Cavin2018-07-191-0/+2
| | | | | | | | | | | | This patch catches the conditions where: - 'splicepoint' is set to a point outside of [ fdt, fdt_totalsize(fdt) ) - 'newlen' is negative, or 'splicepoint' plus 'newlen' results in overflow Either of these cases can be caused by math which overflows in calling functions, or by sizes specified through dynamic means. Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
* libfdt: Initial importSebastian Huber2015-10-161-0/+492
Import from: git://git.kernel.org/pub/scm/utils/dtc/dtc.git Commit: 604e61e081e3c6c8fa1a8189c71cb3908a5bbc1e Date: 2015-09-29T09:09:08Z