Skip to content

Commit e90b81e

Browse files
committed
Merge tag 'dmaengine-fix-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine
Pull dmaengine fixes from Vinod Koul: "A bunch of driver fixes for: - dma mask fix for mmp pdma driver - Xilinx regmap max register, uninitialized addr_width fix - device leak fix for bunch of drivers in the subsystem - stm32 dmamux, TI crossbar driver fixes for device & of node leak and route allocation cleanup - Tegra use afer free fix - Memory leak fix in Qualcomm gpi and omap-dma driver - compatible fix for apple driver" * tag 'dmaengine-fix-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine: (25 commits) dmaengine: apple-admac: Add "apple,t8103-admac" compatible dmaengine: omap-dma: fix dma_pool resource leak in error paths dmaengine: qcom: gpi: Fix memory leak in gpi_peripheral_config() dmaengine: sh: rz-dmac: Fix rz_dmac_terminate_all() dmaengine: xilinx_dma: Fix uninitialized addr_width when "xlnx,addrwidth" property is missing dmaengine: tegra-adma: Fix use-after-free dmaengine: fsl-edma: Fix clk leak on alloc_chan_resources failure dmaengine: mmp_pdma: Fix race condition in mmp_pdma_residue() dmaengine: ti: k3-udma: fix device leak on udma lookup dmaengine: ti: dma-crossbar: clean up dra7x route allocation error paths dmaengine: ti: dma-crossbar: fix device leak on am335x route allocation dmaengine: ti: dma-crossbar: fix device leak on dra7x route allocation dmaengine: stm32: dmamux: clean up route allocation error labels dmaengine: stm32: dmamux: fix OF node leak on route allocation failure dmaengine: stm32: dmamux: fix device leak on route allocation dmaengine: sh: rz-dmac: fix device leak on probe failure dmaengine: lpc32xx-dmamux: fix device leak on route allocation dmaengine: lpc18xx-dmamux: fix device leak on route allocation dmaengine: idxd: fix device leaks on compat bind and unbind dmaengine: dw: dmamux: fix OF node leak on route allocation failure ...
2 parents 3271b25 + 76cba1e commit e90b81e

20 files changed

Lines changed: 168 additions & 73 deletions

drivers/dma/apple-admac.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,7 @@ static void admac_remove(struct platform_device *pdev)
936936
}
937937

938938
static const struct of_device_id admac_of_match[] = {
939+
{ .compatible = "apple,t8103-admac", },
939940
{ .compatible = "apple,admac", },
940941
{ }
941942
};

drivers/dma/at_hdmac.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,7 @@ static int atc_alloc_chan_resources(struct dma_chan *chan)
17651765
static void atc_free_chan_resources(struct dma_chan *chan)
17661766
{
17671767
struct at_dma_chan *atchan = to_at_dma_chan(chan);
1768+
struct at_dma_slave *atslave;
17681769

17691770
BUG_ON(atc_chan_is_enabled(atchan));
17701771

@@ -1774,8 +1775,12 @@ static void atc_free_chan_resources(struct dma_chan *chan)
17741775
/*
17751776
* Free atslave allocated in at_dma_xlate()
17761777
*/
1777-
kfree(chan->private);
1778-
chan->private = NULL;
1778+
atslave = chan->private;
1779+
if (atslave) {
1780+
put_device(atslave->dma_dev);
1781+
kfree(atslave);
1782+
chan->private = NULL;
1783+
}
17791784

17801785
dev_vdbg(chan2dev(chan), "free_chan_resources: done\n");
17811786
}

drivers/dma/bcm-sba-raid.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,7 @@ static int sba_probe(struct platform_device *pdev)
16991699
/* Prealloc channel resource */
17001700
ret = sba_prealloc_channel_resources(sba);
17011701
if (ret)
1702-
goto fail_free_mchan;
1702+
goto fail_put_mbox;
17031703

17041704
/* Check availability of debugfs */
17051705
if (!debugfs_initialized())
@@ -1729,6 +1729,8 @@ static int sba_probe(struct platform_device *pdev)
17291729
fail_free_resources:
17301730
debugfs_remove_recursive(sba->root);
17311731
sba_freeup_channel_resources(sba);
1732+
fail_put_mbox:
1733+
put_device(sba->mbox_dev);
17321734
fail_free_mchan:
17331735
mbox_free_channel(sba->mchan);
17341736
return ret;
@@ -1744,6 +1746,8 @@ static void sba_remove(struct platform_device *pdev)
17441746

17451747
sba_freeup_channel_resources(sba);
17461748

1749+
put_device(sba->mbox_dev);
1750+
17471751
mbox_free_channel(sba->mchan);
17481752
}
17491753

drivers/dma/cv1800b-dmamux.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ static void *cv1800_dmamux_route_allocate(struct of_phandle_args *dma_spec,
102102
struct llist_node *node;
103103
unsigned long flags;
104104
unsigned int chid, devid, cpuid;
105-
int ret;
105+
int ret = -EINVAL;
106106

107107
if (dma_spec->args_count != DMAMUX_NCELLS) {
108108
dev_err(&pdev->dev, "invalid number of dma mux args\n");
109-
return ERR_PTR(-EINVAL);
109+
goto err_put_pdev;
110110
}
111111

112112
devid = dma_spec->args[0];
@@ -115,18 +115,18 @@ static void *cv1800_dmamux_route_allocate(struct of_phandle_args *dma_spec,
115115

116116
if (devid > MAX_DMA_MAPPING_ID) {
117117
dev_err(&pdev->dev, "invalid device id: %u\n", devid);
118-
return ERR_PTR(-EINVAL);
118+
goto err_put_pdev;
119119
}
120120

121121
if (cpuid > MAX_DMA_CPU_ID) {
122122
dev_err(&pdev->dev, "invalid cpu id: %u\n", cpuid);
123-
return ERR_PTR(-EINVAL);
123+
goto err_put_pdev;
124124
}
125125

126126
dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
127127
if (!dma_spec->np) {
128128
dev_err(&pdev->dev, "can't get dma master\n");
129-
return ERR_PTR(-EINVAL);
129+
goto err_put_pdev;
130130
}
131131

132132
spin_lock_irqsave(&dmamux->lock, flags);
@@ -136,8 +136,6 @@ static void *cv1800_dmamux_route_allocate(struct of_phandle_args *dma_spec,
136136
if (map->peripheral == devid && map->cpu == cpuid)
137137
goto found;
138138
}
139-
140-
ret = -EINVAL;
141139
goto failed;
142140
} else {
143141
node = llist_del_first(&dmamux->free_maps);
@@ -171,12 +169,17 @@ static void *cv1800_dmamux_route_allocate(struct of_phandle_args *dma_spec,
171169
dev_dbg(&pdev->dev, "register channel %u for req %u (cpu %u)\n",
172170
chid, devid, cpuid);
173171

172+
put_device(&pdev->dev);
173+
174174
return map;
175175

176176
failed:
177177
spin_unlock_irqrestore(&dmamux->lock, flags);
178178
of_node_put(dma_spec->np);
179179
dev_err(&pdev->dev, "errno %d\n", ret);
180+
err_put_pdev:
181+
put_device(&pdev->dev);
182+
180183
return ERR_PTR(ret);
181184
}
182185

drivers/dma/dw/rzn1-dmamux.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
9090

9191
if (test_and_set_bit(map->req_idx, dmamux->used_chans)) {
9292
ret = -EBUSY;
93-
goto free_map;
93+
goto put_dma_spec_np;
9494
}
9595

9696
mask = BIT(map->req_idx);
@@ -103,6 +103,8 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
103103

104104
clear_bitmap:
105105
clear_bit(map->req_idx, dmamux->used_chans);
106+
put_dma_spec_np:
107+
of_node_put(dma_spec->np);
106108
free_map:
107109
kfree(map);
108110
put_device:

drivers/dma/fsl-edma-common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,7 @@ int fsl_edma_alloc_chan_resources(struct dma_chan *chan)
873873
free_irq(fsl_chan->txirq, fsl_chan);
874874
err_txirq:
875875
dma_pool_destroy(fsl_chan->tcd_pool);
876+
clk_disable_unprepare(fsl_chan->clk);
876877

877878
return ret;
878879
}

drivers/dma/idxd/compat.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@ static ssize_t unbind_store(struct device_driver *drv, const char *buf, size_t c
2020
int rc = -ENODEV;
2121

2222
dev = bus_find_device_by_name(bus, NULL, buf);
23-
if (dev && dev->driver) {
23+
if (!dev)
24+
return -ENODEV;
25+
26+
if (dev->driver) {
2427
device_driver_detach(dev);
2528
rc = count;
2629
}
2730

31+
put_device(dev);
32+
2833
return rc;
2934
}
3035
static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, 0200, NULL, unbind_store);
@@ -38,9 +43,12 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t cou
3843
struct idxd_dev *idxd_dev;
3944

4045
dev = bus_find_device_by_name(bus, NULL, buf);
41-
if (!dev || dev->driver || drv != &dsa_drv.drv)
46+
if (!dev)
4247
return -ENODEV;
4348

49+
if (dev->driver || drv != &dsa_drv.drv)
50+
goto err_put_dev;
51+
4452
idxd_dev = confdev_to_idxd_dev(dev);
4553
if (is_idxd_dev(idxd_dev)) {
4654
alt_drv = driver_find("idxd", bus);
@@ -53,13 +61,20 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t cou
5361
alt_drv = driver_find("user", bus);
5462
}
5563
if (!alt_drv)
56-
return -ENODEV;
64+
goto err_put_dev;
5765

5866
rc = device_driver_attach(alt_drv, dev);
5967
if (rc < 0)
60-
return rc;
68+
goto err_put_dev;
69+
70+
put_device(dev);
6171

6272
return count;
73+
74+
err_put_dev:
75+
put_device(dev);
76+
77+
return rc;
6378
}
6479
static DRIVER_ATTR_IGNORE_LOCKDEP(bind, 0200, NULL, bind_store);
6580

drivers/dma/lpc18xx-dmamux.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,30 +57,31 @@ static void *lpc18xx_dmamux_reserve(struct of_phandle_args *dma_spec,
5757
struct lpc18xx_dmamux_data *dmamux = platform_get_drvdata(pdev);
5858
unsigned long flags;
5959
unsigned mux;
60+
int ret = -EINVAL;
6061

6162
if (dma_spec->args_count != 3) {
6263
dev_err(&pdev->dev, "invalid number of dma mux args\n");
63-
return ERR_PTR(-EINVAL);
64+
goto err_put_pdev;
6465
}
6566

6667
mux = dma_spec->args[0];
6768
if (mux >= dmamux->dma_master_requests) {
6869
dev_err(&pdev->dev, "invalid mux number: %d\n",
6970
dma_spec->args[0]);
70-
return ERR_PTR(-EINVAL);
71+
goto err_put_pdev;
7172
}
7273

7374
if (dma_spec->args[1] > LPC18XX_DMAMUX_MAX_VAL) {
7475
dev_err(&pdev->dev, "invalid dma mux value: %d\n",
7576
dma_spec->args[1]);
76-
return ERR_PTR(-EINVAL);
77+
goto err_put_pdev;
7778
}
7879

7980
/* The of_node_put() will be done in the core for the node */
8081
dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
8182
if (!dma_spec->np) {
8283
dev_err(&pdev->dev, "can't get dma master\n");
83-
return ERR_PTR(-EINVAL);
84+
goto err_put_pdev;
8485
}
8586

8687
spin_lock_irqsave(&dmamux->lock, flags);
@@ -89,7 +90,8 @@ static void *lpc18xx_dmamux_reserve(struct of_phandle_args *dma_spec,
8990
dev_err(&pdev->dev, "dma request %u busy with %u.%u\n",
9091
mux, mux, dmamux->muxes[mux].value);
9192
of_node_put(dma_spec->np);
92-
return ERR_PTR(-EBUSY);
93+
ret = -EBUSY;
94+
goto err_put_pdev;
9395
}
9496

9597
dmamux->muxes[mux].busy = true;
@@ -106,7 +108,14 @@ static void *lpc18xx_dmamux_reserve(struct of_phandle_args *dma_spec,
106108
dev_dbg(&pdev->dev, "mapping dmamux %u.%u to dma request %u\n", mux,
107109
dmamux->muxes[mux].value, mux);
108110

111+
put_device(&pdev->dev);
112+
109113
return &dmamux->muxes[mux];
114+
115+
err_put_pdev:
116+
put_device(&pdev->dev);
117+
118+
return ERR_PTR(ret);
110119
}
111120

112121
static int lpc18xx_dmamux_probe(struct platform_device *pdev)

drivers/dma/lpc32xx-dmamux.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_args *dma_spec,
9595
struct lpc32xx_dmamux_data *dmamux = platform_get_drvdata(pdev);
9696
unsigned long flags;
9797
struct lpc32xx_dmamux *mux = NULL;
98+
int ret = -EINVAL;
9899
int i;
99100

100101
if (dma_spec->args_count != 3) {
101102
dev_err(&pdev->dev, "invalid number of dma mux args\n");
102-
return ERR_PTR(-EINVAL);
103+
goto err_put_pdev;
103104
}
104105

105106
for (i = 0; i < ARRAY_SIZE(lpc32xx_muxes); i++) {
@@ -111,20 +112,20 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_args *dma_spec,
111112
if (!mux) {
112113
dev_err(&pdev->dev, "invalid mux request number: %d\n",
113114
dma_spec->args[0]);
114-
return ERR_PTR(-EINVAL);
115+
goto err_put_pdev;
115116
}
116117

117118
if (dma_spec->args[2] > 1) {
118119
dev_err(&pdev->dev, "invalid dma mux value: %d\n",
119120
dma_spec->args[1]);
120-
return ERR_PTR(-EINVAL);
121+
goto err_put_pdev;
121122
}
122123

123124
/* The of_node_put() will be done in the core for the node */
124125
dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
125126
if (!dma_spec->np) {
126127
dev_err(&pdev->dev, "can't get dma master\n");
127-
return ERR_PTR(-EINVAL);
128+
goto err_put_pdev;
128129
}
129130

130131
spin_lock_irqsave(&dmamux->lock, flags);
@@ -133,7 +134,8 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_args *dma_spec,
133134
dev_err(dev, "dma request signal %d busy, routed to %s\n",
134135
mux->signal, mux->muxval ? mux->name_sel1 : mux->name_sel1);
135136
of_node_put(dma_spec->np);
136-
return ERR_PTR(-EBUSY);
137+
ret = -EBUSY;
138+
goto err_put_pdev;
137139
}
138140

139141
mux->busy = true;
@@ -148,7 +150,14 @@ static void *lpc32xx_dmamux_reserve(struct of_phandle_args *dma_spec,
148150
dev_dbg(dev, "dma request signal %d routed to %s\n",
149151
mux->signal, mux->muxval ? mux->name_sel1 : mux->name_sel1);
150152

153+
put_device(&pdev->dev);
154+
151155
return mux;
156+
157+
err_put_pdev:
158+
put_device(&pdev->dev);
159+
160+
return ERR_PTR(ret);
152161
}
153162

154163
static int lpc32xx_dmamux_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)