From: "Luis R. Rodriguez" <mcgrof@suse.com>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>, Michal Marek <mmarek@suse.cz>,
Jason Douglas <jdouglas@suse.com>,
stefano.stabellini@eu.citrix.com, Takashi Iwai <tiwai@suse.de>,
Henrique de Moraes Holschuh <hmh@debian.org>,
david.vrabel@citrix.com, Jan Beulich <JBeulich@suse.com>,
xen-devel@lists.xenproject.org,
"Luis R. Rodriguez" <mcgrof@do-not-panic.com>,
Borislav Petkov <bp@suse.de>, Olaf Hering <ohering@suse.de>
Subject: Re: [PATCH] misc/xenmicrocode: Upload /lib/firmware/<some blob> to the hypervisor
Date: Tue, 27 Jan 2015 22:54:21 +0100 [thread overview]
Message-ID: <20150127215421.GD19988@wotan.suse.de> (raw)
In-Reply-To: <54C80235.2020302@oracle.com>
On Tue, Jan 27, 2015 at 04:25:09PM -0500, Boris Ostrovsky wrote:
> On 01/27/2015 03:11 PM, Luis R. Rodriguez wrote:
>> + fbuf = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0);
>> +
>> + if ((xc_handle = xc_interface_open(0,0,0)) == 0)
>> + {
>> + fprintf(stderr, "Error opening xc interface: %d (%s)\n",
>> + errno, strerror(errno));
>> + return 1;
>> + }
>> +
>> + if (fbuf == MAP_FAILED)
>> + {
>> + printf("Could not map: error: %d(%s)\n", errno,
>> + strerror(errno));
>> + return errno;
>> + }
>
> Shouldn't this 'if' block directly follow the mmap()?
Sure.
>> +
>> + uc = xc_hypercall_buffer_alloc(xc_handle, uc, len);
>> + memcpy(uc, fbuf, len);
>> +
>> + set_xen_guest_handle(op.u.microcode.data, uc);
>> + op.cmd = XENPF_microcode_update;
>> + op.interface_version = XENPF_INTERFACE_VERSION;
>> + op.u.microcode.length = len;
>> + xc_platform_op(xc_handle, &op);
>> +
>> + xc_hypercall_buffer_free(xc_handle, uc);
>> + xc_interface_close(xc_handle);
>> +
>> + if (munmap(fbuf, len))
>> + {
>> + printf("Could not unmap: %d(%s)\n", errno, strerror(errno));
>> + return errno;
>> + }
>> +
>> + close(fd);
>
> Given that you never close the file on errors this is not really necessary.
> Or you should close it on errors for consistency.
Its not required but I'll do this as I think its better, and while
at it I'll also add a check for xc_hypercall_buffer_alloc() failure
as no check is there for it now. Will send out a v2.
Luis
next prev parent reply other threads:[~2015-01-27 21:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-27 20:11 [PATCH] misc/xenmicrocode: Upload /lib/firmware/<some blob> to the hypervisor Luis R. Rodriguez
2015-01-27 21:25 ` Boris Ostrovsky
2015-01-27 21:54 ` Luis R. Rodriguez [this message]
2015-01-27 22:26 ` Andrew Cooper
2015-01-27 23:17 ` Borislav Petkov
2015-01-28 0:10 ` Andrew Cooper
2015-01-28 8:39 ` Borislav Petkov
2015-01-29 3:21 ` Luis R. Rodriguez
2015-01-29 19:15 ` Borislav Petkov
2015-01-30 1:13 ` Luis R. Rodriguez
2015-01-29 11:36 ` Henrique de Moraes Holschuh
2015-01-29 12:17 ` Borislav Petkov
2015-01-29 17:01 ` Henrique de Moraes Holschuh
2015-01-29 17:30 ` Borislav Petkov
2015-01-29 18:34 ` Andrew Cooper
2015-01-29 20:12 ` Konrad Rzeszutek Wilk
2015-01-30 0:29 ` Andrew Cooper
2015-01-30 14:11 ` Konrad Rzeszutek Wilk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150127215421.GD19988@wotan.suse.de \
--to=mcgrof@suse.com \
--cc=JBeulich@suse.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@suse.de \
--cc=david.vrabel@citrix.com \
--cc=hmh@debian.org \
--cc=jdouglas@suse.com \
--cc=jgross@suse.com \
--cc=mcgrof@do-not-panic.com \
--cc=mmarek@suse.cz \
--cc=ohering@suse.de \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tiwai@suse.de \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.