Commit 3669fa63 authored by Linus Torvalds's avatar Linus Torvalds

Use 'free_pipe_info()' helper function for pipe closedown.

This avoids having fs/fifo.c having to know anything about
pipe data passing details, and cleans up the code.
parent 09a141fe
......@@ -135,12 +135,8 @@ static int fifo_open(struct inode *inode, struct file *filp)
goto err;
err:
if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode)) {
struct pipe_inode_info *info = inode->i_pipe;
inode->i_pipe = NULL;
free_page((unsigned long)info->base);
kfree(info);
}
if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode))
free_pipe_info(inode);
err_nocleanup:
up(PIPE_SEM(*inode));
......
......@@ -322,10 +322,7 @@ pipe_release(struct inode *inode, int decr, int decw)
PIPE_READERS(*inode) -= decr;
PIPE_WRITERS(*inode) -= decw;
if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode)) {
struct pipe_inode_info *info = inode->i_pipe;
inode->i_pipe = NULL;
free_page((unsigned long) info->base);
kfree(info);
free_pipe_info(inode);
} else {
wake_up_interruptible(PIPE_WAIT(*inode));
kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
......@@ -530,6 +527,14 @@ struct file_operations rdwr_pipe_fops = {
.fasync = pipe_rdwr_fasync,
};
void free_pipe_info(struct inode *inode)
{
struct pipe_inode_info *info = inode->i_pipe;
inode->i_pipe = NULL;
free_page((unsigned long)info->base);
kfree(info);
}
struct inode* pipe_new(struct inode* inode)
{
unsigned long page;
......@@ -668,9 +673,7 @@ int do_pipe(int *fd)
close_f12_inode_i:
put_unused_fd(i);
close_f12_inode:
free_page((unsigned long) PIPE_BASE(*inode));
kfree(inode->i_pipe);
inode->i_pipe = NULL;
free_pipe_info(inode);
iput(inode);
close_f12:
put_filp(f2);
......
......@@ -44,5 +44,6 @@ struct pipe_inode_info {
void pipe_wait(struct inode * inode);
struct inode* pipe_new(struct inode* inode);
void free_pipe_info(struct inode* inode);
#endif
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