File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 1919
2020static int pipe_fops_open (struct dfs_fd * fd )
2121{
22+ int rc = 0 ;
2223 rt_device_t device ;
2324 rt_pipe_t * pipe ;
2425
@@ -31,6 +32,11 @@ static int pipe_fops_open(struct dfs_fd *fd)
3132 if (device -> ref_count == 0 )
3233 {
3334 pipe -> fifo = rt_ringbuffer_create (pipe -> bufsz );
35+ if (pipe -> fifo == RT_NULL )
36+ {
37+ rc = - RT_ENOMEM ;
38+ goto __exit ;
39+ }
3440 }
3541
3642 switch (fd -> flags & O_ACCMODE )
@@ -48,9 +54,10 @@ static int pipe_fops_open(struct dfs_fd *fd)
4854 }
4955 device -> ref_count ++ ;
5056
57+ __exit :
5158 rt_mutex_release (& (pipe -> lock ));
5259
53- return 0 ;
60+ return rc ;
5461}
5562
5663static int pipe_fops_close (struct dfs_fd * fd )
@@ -90,7 +97,8 @@ static int pipe_fops_close(struct dfs_fd *fd)
9097
9198 if (device -> ref_count == 1 )
9299 {
93- rt_ringbuffer_destroy (pipe -> fifo );
100+ if (pipe -> fifo != RT_NULL )
101+ rt_ringbuffer_destroy (pipe -> fifo );
94102 pipe -> fifo = RT_NULL ;
95103 }
96104 device -> ref_count -- ;
You can’t perform that action at this time.
0 commit comments