If strdup call fails, one needs to free priv variable.

Signed-off-by: Francois Berder <[email protected]>
---
 boot/bootmeth_android.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/boot/bootmeth_android.c b/boot/bootmeth_android.c
index 1374551dbeb..1d70e8d5c05 100644
--- a/boot/bootmeth_android.c
+++ b/boot/bootmeth_android.c
@@ -252,8 +252,10 @@ static int android_read_bootflow(struct udevice *dev, 
struct bootflow *bflow)
                priv->boot_mode = ANDROID_BOOT_MODE_NORMAL;
                bflow->os_name = strdup("Android");
        }
-       if (!bflow->os_name)
+       if (!bflow->os_name) {
+               free(priv);
                return log_msg_ret("os", -ENOMEM);
+       }
 
        if (priv->boot_mode == ANDROID_BOOT_MODE_BOOTLOADER) {
                /* Clear BCB */
-- 
2.43.0

Reply via email to