common: Drop image.h from common header
[platform/kernel/u-boot.git] / arch / arm / mach-keystone / mon.c
index dd446ab..58995d7 100644 (file)
@@ -1,12 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
- * K2HK: secure kernel command file
+ * K2x: Secure commands file
  *
- * (C) Copyright 2012-2014
- *     Texas Instruments Incorporated, <www.ti.com>
- *
- * SPDX-License-Identifier:     GPL-2.0+
+ * Copyright (C) 2012-2019 Texas Instruments Incorporated - http://www.ti.com/
  */
 
+#include <hang.h>
+#include <image.h>
+#include <asm/unaligned.h>
 #include <common.h>
 #include <command.h>
 #include <mach/mon.h>
@@ -121,9 +122,9 @@ void board_fit_image_post_process(void **p_image, size_t *p_size)
        /*
         * Overwrite the image headers after authentication
         * and decryption. Update size to reflect removal
-        * of header.
+        * of header and restore original file size.
         */
-       *p_size -= KS2_HS_SEC_HEADER_LEN;
+       *p_size = get_unaligned_le32(image + (*p_size - 4));
        memcpy(image, image + KS2_HS_SEC_HEADER_LEN, *p_size);
 
        /*