@@ -196,20 +196,20 @@ static int io_import_umem(struct io_zcrx_ifq *ifq,
196196 ret = sg_alloc_table_from_pages (& mem -> page_sg_table , pages , nr_pages ,
197197 0 , nr_pages << PAGE_SHIFT ,
198198 GFP_KERNEL_ACCOUNT );
199- if (ret )
199+ if (ret ) {
200+ unpin_user_pages (pages , nr_pages );
200201 return ret ;
202+ }
201203
202204 mem -> account_pages = io_count_account_pages (pages , nr_pages );
203205 ret = io_account_mem (ifq -> ctx , mem -> account_pages );
204- if (ret < 0 ) {
206+ if (ret < 0 )
205207 mem -> account_pages = 0 ;
206- return ret ;
207- }
208208
209209 mem -> pages = pages ;
210210 mem -> nr_folios = nr_pages ;
211211 mem -> size = area_reg -> len ;
212- return 0 ;
212+ return ret ;
213213}
214214
215215static void io_release_area_mem (struct io_zcrx_mem * mem )
@@ -379,8 +379,7 @@ static void io_free_rbuf_ring(struct io_zcrx_ifq *ifq)
379379
380380static void io_zcrx_free_area (struct io_zcrx_area * area )
381381{
382- if (area -> ifq )
383- io_zcrx_unmap_area (area -> ifq , area );
382+ io_zcrx_unmap_area (area -> ifq , area );
384383 io_release_area_mem (& area -> mem );
385384
386385 if (area -> mem .account_pages )
@@ -413,6 +412,7 @@ static int io_zcrx_create_area(struct io_zcrx_ifq *ifq,
413412 area = kzalloc (sizeof (* area ), GFP_KERNEL );
414413 if (!area )
415414 goto err ;
415+ area -> ifq = ifq ;
416416
417417 ret = io_import_area (ifq , & area -> mem , area_reg );
418418 if (ret )
@@ -447,7 +447,6 @@ static int io_zcrx_create_area(struct io_zcrx_ifq *ifq,
447447 }
448448
449449 area -> free_count = nr_iovs ;
450- area -> ifq = ifq ;
451450 /* we're only supporting one area per ifq for now */
452451 area -> area_id = 0 ;
453452 area_reg -> rq_area_token = (u64 )area -> area_id << IORING_ZCRX_AREA_SHIFT ;
0 commit comments