Skip to content

Commit 0676181

Browse files
committed
Merge tag 'dmaengine-fix-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine
Pull dmaengine fixes from Vinod Koul: - Intel idxd fixes for idxd_free() handling, refcount underflow on module unload, double free in idxd_setup_wqs() - Qualcomm bam dma missing properties and handing for channels with ees - dw device reference leak in rzn1_dmamux_route_allocate() * tag 'dmaengine-fix-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine: dmaengine: dw: dmamux: Fix device reference leak in rzn1_dmamux_route_allocate dmaengine: ti: edma: Fix memory allocation size for queue_priority_map dmaengine: idxd: Fix double free in idxd_setup_wqs() dmaengine: idxd: Fix refcount underflow on module unload dmaengine: idxd: Remove improper idxd_free dmaengine: qcom: bam_dma: Fix DT error handling for num-channels/ees dt-bindings: dma: qcom: bam-dma: Add missing required properties
2 parents 1519fc7 + aa2e1e4 commit 0676181

File tree

5 files changed

+44
-26
lines changed

5 files changed

+44
-26
lines changed

Documentation/devicetree/bindings/dma/qcom,bam-dma.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,12 @@ required:
9292
anyOf:
9393
- required:
9494
- qcom,powered-remotely
95+
- num-channels
96+
- qcom,num-ees
9597
- required:
9698
- qcom,controlled-remotely
99+
- num-channels
100+
- qcom,num-ees
97101
- required:
98102
- clocks
99103
- clock-names

drivers/dma/dw/rzn1-dmamux.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
4848
u32 mask;
4949
int ret;
5050

51-
if (dma_spec->args_count != RNZ1_DMAMUX_NCELLS)
52-
return ERR_PTR(-EINVAL);
51+
if (dma_spec->args_count != RNZ1_DMAMUX_NCELLS) {
52+
ret = -EINVAL;
53+
goto put_device;
54+
}
5355

5456
map = kzalloc(sizeof(*map), GFP_KERNEL);
55-
if (!map)
56-
return ERR_PTR(-ENOMEM);
57+
if (!map) {
58+
ret = -ENOMEM;
59+
goto put_device;
60+
}
5761

5862
chan = dma_spec->args[0];
5963
map->req_idx = dma_spec->args[4];
@@ -94,12 +98,15 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
9498
if (ret)
9599
goto clear_bitmap;
96100

101+
put_device(&pdev->dev);
97102
return map;
98103

99104
clear_bitmap:
100105
clear_bit(map->req_idx, dmamux->used_chans);
101106
free_map:
102107
kfree(map);
108+
put_device:
109+
put_device(&pdev->dev);
103110

104111
return ERR_PTR(ret);
105112
}

drivers/dma/idxd/init.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -189,27 +189,30 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
189189
idxd->wq_enable_map = bitmap_zalloc_node(idxd->max_wqs, GFP_KERNEL, dev_to_node(dev));
190190
if (!idxd->wq_enable_map) {
191191
rc = -ENOMEM;
192-
goto err_bitmap;
192+
goto err_free_wqs;
193193
}
194194

195195
for (i = 0; i < idxd->max_wqs; i++) {
196196
wq = kzalloc_node(sizeof(*wq), GFP_KERNEL, dev_to_node(dev));
197197
if (!wq) {
198198
rc = -ENOMEM;
199-
goto err;
199+
goto err_unwind;
200200
}
201201

202202
idxd_dev_set_type(&wq->idxd_dev, IDXD_DEV_WQ);
203203
conf_dev = wq_confdev(wq);
204204
wq->id = i;
205205
wq->idxd = idxd;
206-
device_initialize(wq_confdev(wq));
206+
device_initialize(conf_dev);
207207
conf_dev->parent = idxd_confdev(idxd);
208208
conf_dev->bus = &dsa_bus_type;
209209
conf_dev->type = &idxd_wq_device_type;
210210
rc = dev_set_name(conf_dev, "wq%d.%d", idxd->id, wq->id);
211-
if (rc < 0)
212-
goto err;
211+
if (rc < 0) {
212+
put_device(conf_dev);
213+
kfree(wq);
214+
goto err_unwind;
215+
}
213216

214217
mutex_init(&wq->wq_lock);
215218
init_waitqueue_head(&wq->err_queue);
@@ -220,15 +223,20 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
220223
wq->enqcmds_retries = IDXD_ENQCMDS_RETRIES;
221224
wq->wqcfg = kzalloc_node(idxd->wqcfg_size, GFP_KERNEL, dev_to_node(dev));
222225
if (!wq->wqcfg) {
226+
put_device(conf_dev);
227+
kfree(wq);
223228
rc = -ENOMEM;
224-
goto err;
229+
goto err_unwind;
225230
}
226231

227232
if (idxd->hw.wq_cap.op_config) {
228233
wq->opcap_bmap = bitmap_zalloc(IDXD_MAX_OPCAP_BITS, GFP_KERNEL);
229234
if (!wq->opcap_bmap) {
235+
kfree(wq->wqcfg);
236+
put_device(conf_dev);
237+
kfree(wq);
230238
rc = -ENOMEM;
231-
goto err_opcap_bmap;
239+
goto err_unwind;
232240
}
233241
bitmap_copy(wq->opcap_bmap, idxd->opcap_bmap, IDXD_MAX_OPCAP_BITS);
234242
}
@@ -239,13 +247,7 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
239247

240248
return 0;
241249

242-
err_opcap_bmap:
243-
kfree(wq->wqcfg);
244-
245-
err:
246-
put_device(conf_dev);
247-
kfree(wq);
248-
250+
err_unwind:
249251
while (--i >= 0) {
250252
wq = idxd->wqs[i];
251253
if (idxd->hw.wq_cap.op_config)
@@ -254,11 +256,10 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
254256
conf_dev = wq_confdev(wq);
255257
put_device(conf_dev);
256258
kfree(wq);
257-
258259
}
259260
bitmap_free(idxd->wq_enable_map);
260261

261-
err_bitmap:
262+
err_free_wqs:
262263
kfree(idxd->wqs);
263264

264265
return rc;
@@ -1291,10 +1292,12 @@ static void idxd_remove(struct pci_dev *pdev)
12911292
device_unregister(idxd_confdev(idxd));
12921293
idxd_shutdown(pdev);
12931294
idxd_device_remove_debugfs(idxd);
1294-
idxd_cleanup(idxd);
1295+
perfmon_pmu_remove(idxd);
1296+
idxd_cleanup_interrupts(idxd);
1297+
if (device_pasid_enabled(idxd))
1298+
idxd_disable_system_pasid(idxd);
12951299
pci_iounmap(pdev, idxd->reg_base);
12961300
put_device(idxd_confdev(idxd));
1297-
idxd_free(idxd);
12981301
pci_disable_device(pdev);
12991302
}
13001303

drivers/dma/qcom/bam_dma.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,13 +1283,17 @@ static int bam_dma_probe(struct platform_device *pdev)
12831283
if (!bdev->bamclk) {
12841284
ret = of_property_read_u32(pdev->dev.of_node, "num-channels",
12851285
&bdev->num_channels);
1286-
if (ret)
1286+
if (ret) {
12871287
dev_err(bdev->dev, "num-channels unspecified in dt\n");
1288+
return ret;
1289+
}
12881290

12891291
ret = of_property_read_u32(pdev->dev.of_node, "qcom,num-ees",
12901292
&bdev->num_ees);
1291-
if (ret)
1293+
if (ret) {
12921294
dev_err(bdev->dev, "num-ees unspecified in dt\n");
1295+
return ret;
1296+
}
12931297
}
12941298

12951299
ret = clk_prepare_enable(bdev->bamclk);

drivers/dma/ti/edma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,8 +2064,8 @@ static int edma_setup_from_hw(struct device *dev, struct edma_soc_info *pdata,
20642064
* priority. So Q0 is the highest priority queue and the last queue has
20652065
* the lowest priority.
20662066
*/
2067-
queue_priority_map = devm_kcalloc(dev, ecc->num_tc + 1, sizeof(s8),
2068-
GFP_KERNEL);
2067+
queue_priority_map = devm_kcalloc(dev, ecc->num_tc + 1,
2068+
sizeof(*queue_priority_map), GFP_KERNEL);
20692069
if (!queue_priority_map)
20702070
return -ENOMEM;
20712071

0 commit comments

Comments
 (0)