Re: [PATCH v2 1/1] powerpc: fix a memory leak

2023-11-08 Thread kernel test robot
Hi Yuanjun,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.6 next-20231108]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Yuanjun-Gong/powerpc-fix-a-memory-leak/20230915-100832
base:   linus/master
patch link:
https://lore.kernel.org/r/20230915020559.3396566-1-ruc_gongyuanjun%40163.com
patch subject: [PATCH v2 1/1] powerpc: fix a memory leak
config: powerpc-allyesconfig 
(https://download.01.org/0day-ci/archive/20231108/202311081645.j68cla77-...@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 
4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20231108/202311081645.j68cla77-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202311081645.j68cla77-...@intel.com/

All errors (new ones prefixed by >>):

>> arch/powerpc/platforms/powernv/vas.c:105:15: error: expected ';' after 
>> expression
 105 | rc = -ENODEV
 | ^
 | ;
   1 error generated.


vim +105 arch/powerpc/platforms/powernv/vas.c

49  
50  static int init_vas_instance(struct platform_device *pdev)
51  {
52  struct device_node *dn = pdev->dev.of_node;
53  struct vas_instance *vinst;
54  struct xive_irq_data *xd;
55  uint32_t chipid, hwirq;
56  struct resource *res;
57  int rc, cpu, vasid;
58  
59  rc = of_property_read_u32(dn, "ibm,vas-id", );
60  if (rc) {
61  pr_err("No ibm,vas-id property for %s?\n", pdev->name);
62  return -ENODEV;
63  }
64  
65  rc = of_property_read_u32(dn, "ibm,chip-id", );
66  if (rc) {
67  pr_err("No ibm,chip-id property for %s?\n", pdev->name);
68  return -ENODEV;
69  }
70  
71  if (pdev->num_resources != 4) {
72  pr_err("Unexpected DT configuration for [%s, %d]\n",
73  pdev->name, vasid);
74  return -ENODEV;
75  }
76  
77  vinst = kzalloc(sizeof(*vinst), GFP_KERNEL);
78  if (!vinst)
79  return -ENOMEM;
80  
81  vinst->name = kasprintf(GFP_KERNEL, "vas-%d", vasid);
82  if (!vinst->name) {
83  kfree(vinst);
84  return -ENOMEM;
85  }
86  
87  INIT_LIST_HEAD(>node);
88  ida_init(>ida);
89  mutex_init(>mutex);
90  vinst->vas_id = vasid;
91  vinst->pdev = pdev;
92  
93  res = >resource[0];
94  vinst->hvwc_bar_start = res->start;
95  
96  res = >resource[1];
97  vinst->uwc_bar_start = res->start;
98  
99  res = >resource[2];
   100  vinst->paste_base_addr = res->start;
   101  
   102  res = >resource[3];
   103  if (res->end > 62) {
   104  pr_err("Bad 'paste_win_id_shift' in DT, %llx\n", 
res->end);
 > 105  rc = -ENODEV
   106  goto free_vinst;
   107  }
   108  
   109  vinst->paste_win_id_shift = 63 - res->end;
   110  
   111  hwirq = xive_native_alloc_irq_on_chip(chipid);
   112  if (!hwirq) {
   113  pr_err("Inst%d: Unable to allocate global irq for chip 
%d\n",
   114  vinst->vas_id, chipid);
   115  rc = -ENOENT;
   116  goto free_vinst;
   117  }
   118  
   119  vinst->virq = irq_create_mapping(NULL, hwirq);
   120  if (!vinst->virq) {
   121  pr_err("Inst%d: Unable to map global irq %d\n",
   122  vinst->vas_id, hwirq);
   123  rc = -EINVAL;
   124  goto free_vinst;
   125  }
   126  
   127  xd = irq_get_handler_data(vinst->virq);
   128  if (!xd) {
   129  pr_err("Inst%d: Invalid virq %d\n",
   130  vinst->vas_id, vinst->virq);
   131  rc = -EINVAL;
 

Re: [PATCH v2 1/1] powerpc: fix a memory leak

2023-09-23 Thread kernel test robot
Hi Yuanjun,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.6-rc2 next-20230921]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Yuanjun-Gong/powerpc-fix-a-memory-leak/20230915-100832
base:   linus/master
patch link:
https://lore.kernel.org/r/20230915020559.3396566-1-ruc_gongyuanjun%40163.com
patch subject: [PATCH v2 1/1] powerpc: fix a memory leak
config: powerpc-powernv_defconfig 
(https://download.01.org/0day-ci/archive/20230924/202309240954.1h3g2rpy-...@intel.com/config)
compiler: powerpc64le-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20230924/202309240954.1h3g2rpy-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202309240954.1h3g2rpy-...@intel.com/

All errors (new ones prefixed by >>):

   arch/powerpc/platforms/powernv/vas.c: In function 'init_vas_instance':
>> arch/powerpc/platforms/powernv/vas.c:106:17: error: expected ';' before 
>> 'goto'
 106 | goto free_vinst;
 | ^~~~


vim +106 arch/powerpc/platforms/powernv/vas.c

0d17de03ce6a7a Haren Myneni2020-04-15   49  
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   50  static int 
init_vas_instance(struct platform_device *pdev)
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   51  {
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   52  struct device_node *dn 
= pdev->dev.of_node;
c20e1e299d936c Haren Myneni2020-04-15   53  struct vas_instance 
*vinst;
c20e1e299d936c Haren Myneni2020-04-15   54  struct xive_irq_data 
*xd;
c20e1e299d936c Haren Myneni2020-04-15   55  uint32_t chipid, hwirq;
c20e1e299d936c Haren Myneni2020-04-15   56  struct resource *res;
c20e1e299d936c Haren Myneni2020-04-15   57  int rc, cpu, vasid;
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   58  
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   59  rc = 
of_property_read_u32(dn, "ibm,vas-id", );
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   60  if (rc) {
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   61  pr_err("No 
ibm,vas-id property for %s?\n", pdev->name);
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   62  return -ENODEV;
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   63  }
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   64  
c20e1e299d936c Haren Myneni2020-04-15   65  rc = 
of_property_read_u32(dn, "ibm,chip-id", );
c20e1e299d936c Haren Myneni2020-04-15   66  if (rc) {
c20e1e299d936c Haren Myneni2020-04-15   67  pr_err("No 
ibm,chip-id property for %s?\n", pdev->name);
c20e1e299d936c Haren Myneni2020-04-15   68  return -ENODEV;
c20e1e299d936c Haren Myneni2020-04-15   69  }
c20e1e299d936c Haren Myneni2020-04-15   70  
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   71  if (pdev->num_resources 
!= 4) {
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   72  
pr_err("Unexpected DT configuration for [%s, %d]\n",
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   73  
pdev->name, vasid);
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   74  return -ENODEV;
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   75  }
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   76  
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   77  vinst = 
kzalloc(sizeof(*vinst), GFP_KERNEL);
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   78  if (!vinst)
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   79  return -ENOMEM;
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   80  
9dd31b11370380 Cédric Le Goater2020-12-12   81  vinst->name = 
kasprintf(GFP_KERNEL, "vas-%d", vasid);
9dd31b11370380 Cédric Le Goater2020-12-12   82  if (!vinst->name) {
9dd31b11370380 Cédric Le Goater2020-12-12   83  kfree(vinst);
9dd31b11370380 Cédric Le Goater2020-12-12   84  return -ENOMEM;
9dd31b11370380 Cédric Le Goater2020-12-12   85  }
9dd31b11370380 Cédric Le Goater2020-12-12   86  
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   87  
INIT_LIST_HEAD(>node);
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   88  ida_init(>ida);
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   89  
mutex_init(>mutex);
4dea2d1a927c61 Sukadev Bhattiprolu 2017-08-28   90  vinst->vas_id = vasid;
4dea2d1a927c61 Sukadev Bhattiprolu 2017-

[PATCH v2 1/1] powerpc: fix a memory leak

2023-09-14 Thread Yuanjun Gong
When one of the methods xive_native_alloc_irq_on_chip, irq_create_mapping
or irq_get_handler_data fails, the function will directly return without
disposing vinst->name and vinst. Fix it.

Fixes: c20e1e299d93 ("powerpc/vas: Alloc and setup IRQ and trigger port 
address")
Signed-off-by: Yuanjun Gong 
---
 arch/powerpc/platforms/powernv/vas.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/vas.c 
b/arch/powerpc/platforms/powernv/vas.c
index b65256a63e87..40cb7a03d180 100644
--- a/arch/powerpc/platforms/powernv/vas.c
+++ b/arch/powerpc/platforms/powernv/vas.c
@@ -102,6 +102,7 @@ static int init_vas_instance(struct platform_device *pdev)
res = >resource[3];
if (res->end > 62) {
pr_err("Bad 'paste_win_id_shift' in DT, %llx\n", res->end);
+   rc = -ENODEV
goto free_vinst;
}
 
@@ -111,21 +112,24 @@ static int init_vas_instance(struct platform_device *pdev)
if (!hwirq) {
pr_err("Inst%d: Unable to allocate global irq for chip %d\n",
vinst->vas_id, chipid);
-   return -ENOENT;
+   rc = -ENOENT;
+   goto free_vinst;
}
 
vinst->virq = irq_create_mapping(NULL, hwirq);
if (!vinst->virq) {
pr_err("Inst%d: Unable to map global irq %d\n",
vinst->vas_id, hwirq);
-   return -EINVAL;
+   rc = -EINVAL;
+   goto free_vinst;
}
 
xd = irq_get_handler_data(vinst->virq);
if (!xd) {
pr_err("Inst%d: Invalid virq %d\n",
vinst->vas_id, vinst->virq);
-   return -EINVAL;
+   rc = -EINVAL;
+   goto free_vinst;
}
 
vinst->irq_port = xd->trig_page;
@@ -168,7 +172,7 @@ static int init_vas_instance(struct platform_device *pdev)
 free_vinst:
kfree(vinst->name);
kfree(vinst);
-   return -ENODEV;
+   return rc;
 
 }
 
-- 
2.37.2