Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1719564
| From | Dan Carpenter <dan.carpenter@oracle.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2] x86/microcode: Silence a static checker warning |
| Date | 2017-08-24 23:00 +0200 |
| Message-ID | <ui7ol-2YO-7@gated-at.bofh.it> (permalink) |
| References | <ui6LF-2Jv-31@gated-at.bofh.it> <ui6LF-2Jv-29@gated-at.bofh.it> <ui7eG-2Ut-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu, Aug 24, 2017 at 10:47:14PM +0200, Borislav Petkov wrote:
> diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
> index 59edbe9d4ccb..0179f0fd8a79 100644
> --- a/arch/x86/kernel/cpu/microcode/intel.c
> +++ b/arch/x86/kernel/cpu/microcode/intel.c
> @@ -146,7 +146,7 @@ static bool microcode_matches(struct microcode_header_intel *mc_header,
> return false;
> }
>
> -static struct ucode_patch *__alloc_microcode_buf(void *data, unsigned int size)
> +static struct ucode_patch *memdup_patch(void *data, unsigned int size)
> {
> struct ucode_patch *p;
>
> @@ -183,11 +183,13 @@ static void save_microcode_patch(void *data, unsigned int size)
> if (mc_hdr->rev <= mc_saved_hdr->rev)
> continue;
>
> - p = __alloc_microcode_buf(data, size);
> - if (IS_ERR(p))
> + p = memdup_patch(data, size);
> + if (IS_ERR(p)) {
> pr_err("Error allocating buffer %p\n", data);
> - else
> - list_replace(&iter->plist, &p->plist);
> + continue;
> + }
> +
> + list_replace(&iter->plist, &p->plist);
> }
> }
>
This is just cleanups and doesn't change the behavior.
> @@ -196,11 +198,12 @@ static void save_microcode_patch(void *data, unsigned int size)
> * newly found.
> */
> if (!prev_found) {
> - p = __alloc_microcode_buf(data, size);
> - if (IS_ERR(p))
> + p = memdup_patch(data, size);
> + if (IS_ERR(p)) {
> pr_err("Error allocating buffer for %p\n", data);
> - else
> - list_add_tail(&p->plist, µcode_cache);
> + return;
> + }
> + list_add_tail(&p->plist, µcode_cache);
> }
The static checker is still going to complain about the error pointer
from the loop. Perhaps we should only set prev_found if the memdup_patch()
inside the loop succeeds?
regards,
dan carpenter
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2] x86/microcode: Silence a static checker warning Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-24 22:20 +0200
Re: [PATCH v2] x86/microcode: Silence a static checker warning Borislav Petkov <bp@alien8.de> - 2017-08-24 22:50 +0200
Re: [PATCH v2] x86/microcode: Silence a static checker warning Borislav Petkov <bp@alien8.de> - 2017-08-24 23:00 +0200
Re: [PATCH v2] x86/microcode: Silence a static checker warning Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-24 23:10 +0200
Re: [PATCH v2] x86/microcode: Silence a static checker warning Borislav Petkov <bp@alien8.de> - 2017-08-24 23:20 +0200
Re: [PATCH v2] x86/microcode: Silence a static checker warning Borislav Petkov <bp@alien8.de> - 2017-08-25 11:10 +0200
Re: [PATCH v2] x86/microcode: Silence a static checker warning Borislav Petkov <bp@alien8.de> - 2017-08-25 11:20 +0200
[PATCH] x86/microcode/intel: Improve microcode patches saving flow Borislav Petkov <bp@alien8.de> - 2017-08-25 12:10 +0200
Re: [PATCH] x86/microcode/intel: Improve microcode patches saving flow walter harms <wharms@bfs.de> - 2017-08-25 12:50 +0200
Re: [PATCH] x86/microcode/intel: Improve microcode patches saving flow Borislav Petkov <bp@alien8.de> - 2017-08-25 13:50 +0200
[tip:x86/microcode] x86/microcode/intel: Improve microcode patches saving flow tip-bot for Borislav Petkov <tipbot@zytor.com> - 2017-08-29 11:10 +0200
Re: [PATCH v2] x86/microcode: Silence a static checker warning Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-25 11:20 +0200
Re: [PATCH v2] x86/microcode: Silence a static checker warning Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-24 23:00 +0200
Re: [PATCH v2] x86/microcode: Silence a static checker warning Joe Perches <joe@perches.com> - 2017-08-24 23:10 +0200
csiph-web