Commit 72dc571a authored by Borislav Petkov's avatar Borislav Petkov

x86/microcode/AMD: Fix container size's type

Make it size_t everywhere as this is what we get from cpio.

 [ bp: Fix a smatch warning. ]
Originally-by: default avatarMaciej S. Szmigiero <mail@maciej.szmigiero.name>
Reported-by: default avatarkbuild test robot <lkp@intel.com>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20181107170218.7596-13-bp@alien8.de
parent c45e8035
...@@ -186,8 +186,7 @@ __verify_patch_section(const u8 *buf, size_t buf_size, u32 *sh_psize, bool early ...@@ -186,8 +186,7 @@ __verify_patch_section(const u8 *buf, size_t buf_size, u32 *sh_psize, bool early
* exceed the per-family maximum). @sh_psize is the size read from the section * exceed the per-family maximum). @sh_psize is the size read from the section
* header. * header.
*/ */
static unsigned int static unsigned int __verify_patch_size(u8 family, u32 sh_psize, size_t buf_size)
__verify_patch_size(u8 family, u32 sh_psize, unsigned int buf_size)
{ {
u32 max_size; u32 max_size;
...@@ -285,10 +284,10 @@ verify_patch(u8 family, const u8 *buf, size_t buf_size, u32 *patch_size, bool ea ...@@ -285,10 +284,10 @@ verify_patch(u8 family, const u8 *buf, size_t buf_size, u32 *patch_size, bool ea
* Returns the amount of bytes consumed while scanning. @desc contains all the * Returns the amount of bytes consumed while scanning. @desc contains all the
* data we're going to use in later stages of the application. * data we're going to use in later stages of the application.
*/ */
static ssize_t parse_container(u8 *ucode, ssize_t size, struct cont_desc *desc) static size_t parse_container(u8 *ucode, size_t size, struct cont_desc *desc)
{ {
struct equiv_cpu_entry *eq; struct equiv_cpu_entry *eq;
ssize_t orig_size = size; size_t orig_size = size;
u32 *hdr = (u32 *)ucode; u32 *hdr = (u32 *)ucode;
u16 eq_id; u16 eq_id;
u8 *buf; u8 *buf;
...@@ -366,15 +365,18 @@ static ssize_t parse_container(u8 *ucode, ssize_t size, struct cont_desc *desc) ...@@ -366,15 +365,18 @@ static ssize_t parse_container(u8 *ucode, ssize_t size, struct cont_desc *desc)
*/ */
static void scan_containers(u8 *ucode, size_t size, struct cont_desc *desc) static void scan_containers(u8 *ucode, size_t size, struct cont_desc *desc)
{ {
ssize_t rem = size; while (size) {
size_t s = parse_container(ucode, size, desc);
while (rem >= 0) {
ssize_t s = parse_container(ucode, rem, desc);
if (!s) if (!s)
return; return;
ucode += s; /* catch wraparound */
rem -= s; if (size >= s) {
ucode += s;
size -= s;
} else {
return;
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment