mirror of
https://github.com/raspberrypi/userland.git
synced 2025-12-06 04:49:12 +00:00
dtoverlay: Short-circuit empty parameter handling
Return success early if a parameter declaration has an empty body, to avoid mallocing a zero-length block and save time.
This commit is contained in:
@@ -1328,6 +1328,11 @@ int dtoverlay_foreach_override_target(DTBLOB_T *dtb, const char *override_name,
|
|||||||
int target_phandle = 0;
|
int target_phandle = 0;
|
||||||
char *data;
|
char *data;
|
||||||
|
|
||||||
|
/* Short-circuit the degenerate case of an empty parameter, avoiding an
|
||||||
|
apparent memory allocation failure. */
|
||||||
|
if (!data_len)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* Copy the override data in case it moves */
|
/* Copy the override data in case it moves */
|
||||||
data = malloc(data_len);
|
data = malloc(data_len);
|
||||||
if (!data)
|
if (!data)
|
||||||
|
|||||||
Reference in New Issue
Block a user