Commit 295d4eb5 authored by Stéphane Eranian's avatar Stéphane Eranian Committed by Tony Luck

[IA64] perfmon.c: file descriptor fixes

  - fix pfm_free_fd() to clear current->files->fd[fd] in
    case of error during PFM_CONTEXT_CREATE, i.e., undo
    the effect of fd_install(). This could cause kernel
    panic if the file descriptor gets used by error through
    perfmon.
  - fix pfm_context_create() to correctly propagate the
    return value of pfm_alloc_fd().
signed-off-by: default avatarstephane eranian <eranian@hpl.hp.com>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent 65fd90f1
...@@ -2227,6 +2227,15 @@ pfm_alloc_fd(struct file **cfile) ...@@ -2227,6 +2227,15 @@ pfm_alloc_fd(struct file **cfile)
static void static void
pfm_free_fd(int fd, struct file *file) pfm_free_fd(int fd, struct file *file)
{ {
struct files_struct *files = current->files;
/*
* there ie no fd_uninstall(), so we do it here
*/
spin_lock(&files->file_lock);
files->fd[fd] = NULL;
spin_unlock(&files->file_lock);
if (file) put_filp(file); if (file) put_filp(file);
put_unused_fd(fd); put_unused_fd(fd);
} }
...@@ -2659,8 +2668,10 @@ pfm_context_create(pfm_context_t *ctx, void *arg, int count, struct pt_regs *reg ...@@ -2659,8 +2668,10 @@ pfm_context_create(pfm_context_t *ctx, void *arg, int count, struct pt_regs *reg
ctx = pfm_context_alloc(); ctx = pfm_context_alloc();
if (!ctx) goto error; if (!ctx) goto error;
req->ctx_fd = ctx->ctx_fd = pfm_alloc_fd(&filp); ret = pfm_alloc_fd(&filp);
if (req->ctx_fd < 0) goto error_file; if (ret < 0) goto error_file;
req->ctx_fd = ctx->ctx_fd = ret;
/* /*
* attach context to file * attach context to file
......
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