On Mon, Dec 16, 2024 at 07:26:09PM +0900, Joe Hattori wrote: > The .probe() of edma_driver calls of_parse_phandle_with_fixed_args() but > does not release the obtained OF nodes. Thus implement > edma_cleanup_tc_list(), which releases those OF nodes, and call it in > the error path of .probe() and in .remove(). > > This bug was found by an experimental static analysis tool that I am > developing. > > Fixes: 1be5336bc7ba ("dmaengine: edma: New device tree binding") > Signed-off-by: Joe Hattori <joe@xxxxxxxxxxxxxxxxxxxxx> > --- > drivers/dma/ti/edma.c | 23 +++++++++++++++++++---- > 1 file changed, 19 insertions(+), 4 deletions(-) > > diff --git a/drivers/dma/ti/edma.c b/drivers/dma/ti/edma.c > index 343e986e66e7..e6eee6cfa94a 100644 > --- a/drivers/dma/ti/edma.c > +++ b/drivers/dma/ti/edma.c > @@ -2279,6 +2279,18 @@ static struct dma_chan *of_edma_xlate(struct of_phandle_args *dma_spec, > > static bool edma_filter_fn(struct dma_chan *chan, void *param); > > +static void edma_cleanup_tc_list(struct edma_cc *ecc) > +{ > + int i; > + > + if (!ecc->tc_list) > + return; > + for (i = 0; i < ecc->num_tc; i++) { > + if (ecc->tc_list[i].node) > + of_node_put(ecc->tc_list[i].node); No need for this NULL check. In a way, it would be cleanest to just get rid of the .node struct member. We never use it. We could just save the .id and call of_node_put() right away in probe. That's really how it's normally done. regards, dan carpenter