Skip to content

Commit 63e8b94

Browse files
dinghaoliuVasily Gorbik
authored andcommitted
s390/cio: fix a memleak in css_alloc_subchannel
When dma_set_coherent_mask() fails, sch->lock has not been freed, which is allocated in css_sch_create_locks(), leading to a memleak. Fixes: 4520a91 ("s390/cio: use dma helpers for setting masks") Signed-off-by: Dinghao Liu <[email protected]> Message-Id: <[email protected]> Link: https://lore.kernel.org/linux-s390/[email protected]/ Reviewed-by: Halil Pasic <[email protected]> Reviewed-by: Peter Oberparleiter <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent 5c95bf2 commit 63e8b94

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/s390/cio/css.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,17 +233,19 @@ struct subchannel *css_alloc_subchannel(struct subchannel_id schid,
233233
*/
234234
ret = dma_set_coherent_mask(&sch->dev, DMA_BIT_MASK(31));
235235
if (ret)
236-
goto err;
236+
goto err_lock;
237237
/*
238238
* But we don't have such restrictions imposed on the stuff that
239239
* is handled by the streaming API.
240240
*/
241241
ret = dma_set_mask(&sch->dev, DMA_BIT_MASK(64));
242242
if (ret)
243-
goto err;
243+
goto err_lock;
244244

245245
return sch;
246246

247+
err_lock:
248+
kfree(sch->lock);
247249
err:
248250
kfree(sch);
249251
return ERR_PTR(ret);

0 commit comments

Comments
 (0)