All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>,
	stefano.stabellini@eu.citrix.com
Cc: Juergen Gross <jgross@suse.com>, Michal Marek <mmarek@suse.cz>,
	Jason Douglas <jdouglas@suse.com>, Takashi Iwai <tiwai@suse.de>,
	mcgrof@suse.com, Henrique de Moraes Holschuh <hmh@debian.org>,
	david.vrabel@citrix.com, Jan Beulich <JBeulich@suse.com>,
	xen-devel@lists.xenproject.org, 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 16:25:09 -0500	[thread overview]
Message-ID: <54C80235.2020302@oracle.com> (raw)
In-Reply-To: <1422389461-19333-1-git-send-email-mcgrof@do-not-panic.com>

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()?

> +
> +    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.


-boris

  reply	other threads:[~2015-01-27 21:25 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 [this message]
2015-01-27 21:54   ` Luis R. Rodriguez
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=54C80235.2020302@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=JBeulich@suse.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=mcgrof@suse.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.