drivers/net/ethernet/freescale/gianfar.c:580 gfar_parse_group() warn: 'grp->regs' not released on lines: 517.
Hi Rasmus, First bad commit (maybe != root cause): tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: f01c30de86f1047e9bae1b1b1417b0ce8dcd15b1 commit: 5a35435ef4e6e4bd2aabd6706b146b298a9cffe5 soc: fsl: qe: remove PPC32 dependency from CONFIG_QUICC_ENGINE config: powerpc64-randconfig-m031-20201113 (attached as .config) compiler: powerpc64-linux-gcc (GCC) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot Reported-by: Dan Carpenter smatch warnings: drivers/net/ethernet/freescale/gianfar.c:580 gfar_parse_group() warn: 'grp->regs' not released on lines: 517. vim +580 drivers/net/ethernet/freescale/gianfar.c 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet 2009-11-02 491 static int gfar_parse_group(struct device_node *np, 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet 2009-11-02 492 struct gfar_private *priv, const char *model) 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet 2009-11-02 493 { 5fedcc14d40e355 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 494 struct gfar_priv_grp *grp = &priv->gfargrp[priv->num_grps]; ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 495 int i; ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 496 ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 497 for (i = 0; i < GFAR_NUM_IRQS; i++) { ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 498 grp->irqinfo[i] = kzalloc(sizeof(struct gfar_irqinfo), ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 499 GFP_KERNEL); ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 500 if (!grp->irqinfo[i]) ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 501 return -ENOMEM; ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 502 } 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet 2009-11-02 503 5fedcc14d40e355 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 504 grp->regs = of_iomap(np, 0); ^^^ 5fedcc14d40e355 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 505 if (!grp->regs) 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet 2009-11-02 506 return -ENOMEM; 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet 2009-11-02 507 ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 508 gfar_irq(grp, TX)->irq = irq_of_parse_and_map(np, 0); 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet 2009-11-02 509 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet 2009-11-02 510 /* If we aren't the FEC we have multiple interrupts */ 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet 2009-11-02 511 if (model && strcasecmp(model, "FEC")) { ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 512 gfar_irq(grp, RX)->irq = irq_of_parse_and_map(np, 1); ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 513 gfar_irq(grp, ER)->irq = irq_of_parse_and_map(np, 2); fea0f6650979a4f drivers/net/ethernet/freescale/gianfar.c Mark Brown 2015-11-26 514 if (!gfar_irq(grp, TX)->irq || fea0f6650979a4f drivers/net/ethernet/freescale/gianfar.c Mark Brown 2015-11-26 515 !gfar_irq(grp, RX)->irq || fea0f6650979a4f drivers/net/ethernet/freescale/gianfar.c Mark Brown 2015-11-26 516 !gfar_irq(grp, ER)->irq) 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet 2009-11-02 517 return -EINVAL; This should unmap "grp->regs". 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet 2009-11-02 518 } 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet 2009-11-02 519 5fedcc14d40e355 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 520 grp->priv = priv; 5fedcc14d40e355 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil 2013-01-29 521 spin_lock_init(&grp->grplock); 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet 2009-11-02 522 if (priv-
RE: drivers/net/ethernet/freescale/gianfar.c:580 gfar_parse_group() warn: 'grp->regs' not released on lines: 517.
> -Original Message- > From: Dan Carpenter > Sent: Monday, November 16, 2020 3:25 AM > To: kbu...@lists.01.org; Rasmus Villemoes > Cc: l...@intel.com; Dan Carpenter ; kbuild- > a...@lists.01.org; linux-kernel@vger.kernel.org; Leo Li ; > Timur Tabi > Subject: drivers/net/ethernet/freescale/gianfar.c:580 gfar_parse_group() > warn: 'grp->regs' not released on lines: 517. > > Hi Rasmus, > > First bad commit (maybe != root cause): > > tree: > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ke > rnel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git&a > mp;data=04%7C01%7Cleoyang.li%40nxp.com%7Cfcd86334161e4c85f12408d8 > 8a11d649%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6374111565 > 08189838%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoi > V2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Zvr6xt8Ew > NKnUbBs1NMdnLf8xfeYbDGy1yASNs21pKU%3D&reserved=0 master > head: f01c30de86f1047e9bae1b1b1417b0ce8dcd15b1 > commit: 5a35435ef4e6e4bd2aabd6706b146b298a9cffe5 soc: fsl: qe: remove > PPC32 dependency from CONFIG_QUICC_ENGINE It is strange that this driver is not related to the commit above. > config: powerpc64-randconfig-m031-20201113 (attached as .config) > compiler: powerpc64-linux-gcc (GCC) 9.3.0 > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot > Reported-by: Dan Carpenter > > smatch warnings: > drivers/net/ethernet/freescale/gianfar.c:580 gfar_parse_group() warn: 'grp- > >regs' not released on lines: 517. > > vim +580 drivers/net/ethernet/freescale/gianfar.c > > 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet > 2009-11- > 02 491 static int gfar_parse_group(struct device_node *np, > 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet > 2009-11- > 02 492 struct gfar_private *priv, const char > *model) > 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet > 2009-11- > 02 493 { > 5fedcc14d40e355 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil > 2013-01-29 494 struct gfar_priv_grp *grp = &priv->gfargrp[priv- > >num_grps]; > ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil > 2013-01-29 495 int i; > ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil > 2013-01-29 496 > ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil > 2013-01-29 497 for (i = 0; i < GFAR_NUM_IRQS; i++) { > ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil > 2013-01-29 498 grp->irqinfo[i] = kzalloc(sizeof(struct > gfar_irqinfo), > ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil > 2013-01-29 499 GFP_KERNEL); > ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil > 2013-01-29 500 if (!grp->irqinfo[i]) > ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil > 2013-01-29 501 return -ENOMEM; > ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil > 2013-01-29 502 } > 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet > 2009-11- > 02 503 > 5fedcc14d40e355 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil > 2013-01-29 504 grp->regs = of_iomap(np, 0); > > ^^^ > > 5fedcc14d40e355 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil > 2013-01-29 505 if (!grp->regs) > 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet > 2009-11- > 02 506 return -ENOMEM; > 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet > 2009-11- > 02 507 > ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil > 2013-01-29 508 gfar_irq(grp, TX)->irq = irq_of_parse_and_map(np, > 0); > 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet > 2009-11- > 02 509 > 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet > 2009-11- > 02 510 /* If we aren't the FEC we have multiple interrupts */ > 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet > 2009-11- > 02 511 if (model && strcasecmp(model, "FEC")) { > ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil > 2013-01-29 512 gfar_irq(grp, RX)->irq = > irq_of_parse_and_map(n
Re: drivers/net/ethernet/freescale/gianfar.c:580 gfar_parse_group() warn: 'grp->regs' not released on lines: 517.
On Tue, Nov 17, 2020 at 01:41:15AM +, Leo Li wrote: > > ee873fda3bec7c6 drivers/net/ethernet/freescale/gianfar.c Claudiu Manoil > > 2013-01-29 513 gfar_irq(grp, ER)->irq = > > irq_of_parse_and_map(np, 2); > > fea0f6650979a4f drivers/net/ethernet/freescale/gianfar.c Mark Brown > > 2015-11-26 514 if (!gfar_irq(grp, TX)->irq || > > fea0f6650979a4f drivers/net/ethernet/freescale/gianfar.c Mark Brown > > 2015-11-26 515 !gfar_irq(grp, RX)->irq || > > fea0f6650979a4f drivers/net/ethernet/freescale/gianfar.c Mark Brown > > 2015-11-26 516 !gfar_irq(grp, ER)->irq) > > 46ceb60ca80fa07 drivers/net/gianfar.cSandeep Gopalpet > > 2009-11- > > 02 517 return -EINVAL; > > > > This should unmap "grp->regs". > > This variable is unmapped in the caller with a wholesale cleanup function > unmap_group_regs(). Probably a false positive for smatch? > Yeah. Thanks. Smatch doesn't consider that the variable might be freed in the caller. regards, dan carpenter