@@ -1071,6 +1071,8 @@ static struct kioctx *lookup_ioctx(unsigned long ctx_id)
1071
1071
1072
1072
static inline void iocb_destroy (struct aio_kiocb * iocb )
1073
1073
{
1074
+ if (iocb -> ki_eventfd )
1075
+ eventfd_ctx_put (iocb -> ki_eventfd );
1074
1076
if (iocb -> ki_filp )
1075
1077
fput (iocb -> ki_filp );
1076
1078
percpu_ref_put (& iocb -> ki_ctx -> reqs );
@@ -1138,10 +1140,8 @@ static void aio_complete(struct aio_kiocb *iocb)
1138
1140
* eventfd. The eventfd_signal() function is safe to be called
1139
1141
* from IRQ context.
1140
1142
*/
1141
- if (iocb -> ki_eventfd ) {
1143
+ if (iocb -> ki_eventfd )
1142
1144
eventfd_signal (iocb -> ki_eventfd , 1 );
1143
- eventfd_ctx_put (iocb -> ki_eventfd );
1144
- }
1145
1145
1146
1146
/*
1147
1147
* We have to order our ring_info tail store above and test
@@ -1807,18 +1807,19 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,
1807
1807
goto out_put_req ;
1808
1808
1809
1809
if (iocb -> aio_flags & IOCB_FLAG_RESFD ) {
1810
+ struct eventfd_ctx * eventfd ;
1810
1811
/*
1811
1812
* If the IOCB_FLAG_RESFD flag of aio_flags is set, get an
1812
1813
* instance of the file* now. The file descriptor must be
1813
1814
* an eventfd() fd, and will be signaled for each completed
1814
1815
* event using the eventfd_signal() function.
1815
1816
*/
1816
- req -> ki_eventfd = eventfd_ctx_fdget ((int ) iocb -> aio_resfd );
1817
- if (IS_ERR (req -> ki_eventfd )) {
1818
- ret = PTR_ERR (req -> ki_eventfd );
1819
- req -> ki_eventfd = NULL ;
1817
+ eventfd = eventfd_ctx_fdget (iocb -> aio_resfd );
1818
+ if (IS_ERR (eventfd )) {
1819
+ ret = PTR_ERR (eventfd );
1820
1820
goto out_put_req ;
1821
1821
}
1822
+ req -> ki_eventfd = eventfd ;
1822
1823
}
1823
1824
1824
1825
ret = put_user (KIOCB_KEY , & user_iocb -> aio_key );
@@ -1872,8 +1873,6 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb,
1872
1873
return 0 ;
1873
1874
1874
1875
out_put_req :
1875
- if (req -> ki_eventfd )
1876
- eventfd_ctx_put (req -> ki_eventfd );
1877
1876
iocb_destroy (req );
1878
1877
out_put_reqs_available :
1879
1878
put_reqs_available (ctx , 1 );
0 commit comments