Messages in this thread | | | Date | Wed, 26 Nov 2008 14:33:53 +0100 | From | Ingo Molnar <> | Subject | Re: [patch 15/24] perfmon: context creation |
| |
* eranian@googlemail.com <eranian@googlemail.com> wrote:
> +/** > + * pfm_undo_create -- undo context creation > + * @fd: file descriptor to close > + * @ctx: newly created context > + * > + * upon return neither fd nor ctx are useable > + */ > +void pfm_undo_create(int fd, struct pfm_context *ctx) > +{ > + struct files_struct *files = current->files; > + struct file *file; > + int fput_needed; > + > + file = fget_light(fd, &fput_needed); > + /* > + * there is no fd_uninstall(), so we do it > + * here. put_unused_fd() does not remove the > + * effect of fd_install(). > + */ > + > + spin_lock(&files->file_lock); > + files->fd_array[fd] = NULL; > + spin_unlock(&files->file_lock); > + > + fput_light(file, fput_needed); > + > + /* > + * decrement ref count and kill file > + */ > + put_filp(file); > + > + put_unused_fd(fd); > + > + pfm_free_context(ctx); > +}
This function is superfluous.
The only place where this is used is when a fresh sys_pfm_create() fails to do a user-copy of the sif:
+ if (ureq && copy_to_user(ureq, &sif, sizeof(sif))) { + pfm_undo_create(ret, new_ctx); + ret = -EFAULT; + }
but this code should be calling sys_close(fd) instead - the fd is already set up with pfm_fs so it will tear down the context if this was the last user of the perfmon context.
So basically pfm_undo_create() is an open-coded sys_close(fd).
Ingo
| |