@@ -179,27 +179,30 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
179179 idxd -> wq_enable_map = bitmap_zalloc_node (idxd -> max_wqs , GFP_KERNEL , dev_to_node (dev ));
180180 if (!idxd -> wq_enable_map ) {
181181 rc = - ENOMEM ;
182- goto err_bitmap ;
182+ goto err_free_wqs ;
183183 }
184184
185185 for (i = 0 ; i < idxd -> max_wqs ; i ++ ) {
186186 wq = kzalloc_node (sizeof (* wq ), GFP_KERNEL , dev_to_node (dev ));
187187 if (!wq ) {
188188 rc = - ENOMEM ;
189- goto err ;
189+ goto err_unwind ;
190190 }
191191
192192 idxd_dev_set_type (& wq -> idxd_dev , IDXD_DEV_WQ );
193193 conf_dev = wq_confdev (wq );
194194 wq -> id = i ;
195195 wq -> idxd = idxd ;
196- device_initialize (wq_confdev ( wq ) );
196+ device_initialize (conf_dev );
197197 conf_dev -> parent = idxd_confdev (idxd );
198198 conf_dev -> bus = & dsa_bus_type ;
199199 conf_dev -> type = & idxd_wq_device_type ;
200200 rc = dev_set_name (conf_dev , "wq%d.%d" , idxd -> id , wq -> id );
201- if (rc < 0 )
202- goto err ;
201+ if (rc < 0 ) {
202+ put_device (conf_dev );
203+ kfree (wq );
204+ goto err_unwind ;
205+ }
203206
204207 mutex_init (& wq -> wq_lock );
205208 init_waitqueue_head (& wq -> err_queue );
@@ -210,15 +213,20 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
210213 wq -> enqcmds_retries = IDXD_ENQCMDS_RETRIES ;
211214 wq -> wqcfg = kzalloc_node (idxd -> wqcfg_size , GFP_KERNEL , dev_to_node (dev ));
212215 if (!wq -> wqcfg ) {
216+ put_device (conf_dev );
217+ kfree (wq );
213218 rc = - ENOMEM ;
214- goto err ;
219+ goto err_unwind ;
215220 }
216221
217222 if (idxd -> hw .wq_cap .op_config ) {
218223 wq -> opcap_bmap = bitmap_zalloc (IDXD_MAX_OPCAP_BITS , GFP_KERNEL );
219224 if (!wq -> opcap_bmap ) {
225+ kfree (wq -> wqcfg );
226+ put_device (conf_dev );
227+ kfree (wq );
220228 rc = - ENOMEM ;
221- goto err_opcap_bmap ;
229+ goto err_unwind ;
222230 }
223231 bitmap_copy (wq -> opcap_bmap , idxd -> opcap_bmap , IDXD_MAX_OPCAP_BITS );
224232 }
@@ -229,13 +237,7 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
229237
230238 return 0 ;
231239
232- err_opcap_bmap :
233- kfree (wq -> wqcfg );
234-
235- err :
236- put_device (conf_dev );
237- kfree (wq );
238-
240+ err_unwind :
239241 while (-- i >= 0 ) {
240242 wq = idxd -> wqs [i ];
241243 if (idxd -> hw .wq_cap .op_config )
@@ -244,11 +246,10 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
244246 conf_dev = wq_confdev (wq );
245247 put_device (conf_dev );
246248 kfree (wq );
247-
248249 }
249250 bitmap_free (idxd -> wq_enable_map );
250251
251- err_bitmap :
252+ err_free_wqs :
252253 kfree (idxd -> wqs );
253254
254255 return rc ;
@@ -904,10 +905,12 @@ static void idxd_remove(struct pci_dev *pdev)
904905 device_unregister (idxd_confdev (idxd ));
905906 idxd_shutdown (pdev );
906907 idxd_device_remove_debugfs (idxd );
907- idxd_cleanup (idxd );
908+ perfmon_pmu_remove (idxd );
909+ idxd_cleanup_interrupts (idxd );
910+ if (device_pasid_enabled (idxd ))
911+ idxd_disable_system_pasid (idxd );
908912 pci_iounmap (pdev , idxd -> reg_base );
909913 put_device (idxd_confdev (idxd ));
910- idxd_free (idxd );
911914 pci_disable_device (pdev );
912915}
913916
0 commit comments