Skip to contentSkip to conversation

ACPI: Introduce CPU performance controls using CPPC

PATCH Applied Dan Carpenter 3 participants 6 messages Oct 22, 2015 – Oct 28, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello Ashwin Chaugule,

The patch 337aadff8e45: "ACPI: Introduce CPU performance controls using CPPC" from Oct 2, 2015, leads to the following static checker warning:

drivers/acpi/cppc_acpi.c:527 acpi_cppc_processor_probe()
warn: overwrite may leak 'cpc_ptr'

drivers/acpi/cppc_acpi.c
426 cpc_ptr = kzalloc(sizeof(struct cpc_desc), GFP_KERNEL);
427 if (!cpc_ptr) {
428 ret = -ENOMEM;
429 goto out_buf_free;
430 }
431

   432          /* First entry is NumEntries. */
   433          cpc_obj = &out_obj->package.elements[0];
   434          if (cpc_obj->type == ACPI_TYPE_INTEGER) {

435 num_ent = cpc_obj->integer.value;
436 } else {
437 pr_debug("Unexpected entry type(%d) for NumEntries\n",
438 cpc_obj->type);
439 goto out_free;
440 }

[ snip ]

   523          kfree(output.pointer);
   524          return 0;
   525  
   526  out_free:
   527          cpc_ptr = per_cpu(cpc_desc_ptr, pr->id);

Why do we have this line? Maybe it is left over and should be deleted?

   528          kfree(cpc_ptr);
   529  
   530  out_buf_free:
   531          kfree(output.pointer);
   532          return ret;
   533  }

regards,
dan carpenter

#1 lore raw

Hi Dan,

Quoted 28 lines · Dan Carpenter

Hello Ashwin Chaugule,

The patch 337aadff8e45: "ACPI: Introduce CPU performance controls using CPPC" from Oct 2, 2015, leads to the following static checker warning:

drivers/acpi/cppc_acpi.c:527 acpi_cppc_processor_probe()
warn: overwrite may leak 'cpc_ptr'

drivers/acpi/cppc_acpi.c

   426          cpc_ptr = kzalloc(sizeof(struct cpc_desc), GFP_KERNEL);
   427          if (!cpc_ptr) {
   428                  ret = -ENOMEM;
   429                  goto out_buf_free;
   430          }
   431
   432          /* First entry is NumEntries. */
   433          cpc_obj = &out_obj->package.elements[0];
   434          if (cpc_obj->type == ACPI_TYPE_INTEGER) {
   435                  num_ent = cpc_obj->integer.value;
   436          } else {
   437                  pr_debug("Unexpected entry type(%d) for NumEntries\n",
   438                                  cpc_obj->type);
   439                  goto out_free;
   440          }

[ snip ]

Quoted 7 lines
   523          kfree(output.pointer);
   524          return 0;
   525
   526  out_free:
   527          cpc_ptr = per_cpu(cpc_desc_ptr, pr->id);

Why do we have this line? Maybe it is left over and should be deleted?

Gah! You're right. This is a left over and should be deleted. I can send the fix to Rafael, if you dont have one ready to send?

Thanks,
Ashwin.

#2 lore raw
Quoted 2 lines · Ashwin Chaugule

Gah! You're right. This is a left over and should be deleted. I can send the fix to Rafael, if you dont have one ready to send?

Can you send it? Please give me a Reported-by tag.

regards,
dan carpenter

#3 lore raw
Quoted 5 lines · Dan Carpenter
Quoted 2 lines · Ashwin Chaugule

Gah! You're right. This is a left over and should be deleted. I can send the fix to Rafael, if you dont have one ready to send?

Can you send it? Please give me a Reported-by tag.

Sure. Will do.

Thanks,
Ashwin.

#4 lore raw

PATCH 1/1 CPPC: Fix potential ptr leak

In reply to Dan Carpenter

The patch 337aadff8e45: "ACPI: Introduce CPU performance controls using CPPC" from Oct 2, 2015, leads to the following static checker warning:

drivers/acpi/cppc_acpi.c:527 acpi_cppc_processor_probe()
warn: overwrite may leak 'cpc_ptr'

Fix warning by removing bogus per cpu ptr dereference.

---
 drivers/acpi/cppc_acpi.c | 1 -
 1 file changed, 1 deletion(-)
drivers/acpi/cppc_acpi.c +0 -1
index 0bbf84b..8ca4c2c 100644
@@ -524,7 +524,6 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
 	return 0;
 
 out_free:
-	cpc_ptr = per_cpu(cpc_desc_ptr, pr->id);
 	kfree(cpc_ptr);
 
 out_buf_free:
Signature · 1 line
1.9.1
#5 lore raw

Re: [PATCH] CPPC: Fix potential ptr leak

Quoted 20 lines · Ashwin Chaugule

The patch 337aadff8e45: "ACPI: Introduce CPU performance controls using CPPC" from Oct 2, 2015, leads to the following static checker warning:

drivers/acpi/cppc_acpi.c:527 acpi_cppc_processor_probe()
warn: overwrite may leak 'cpc_ptr'

Fix warning by removing bogus per cpu ptr dereference.

---
 drivers/acpi/cppc_acpi.c | 1 -
 1 file changed, 1 deletion(-)
drivers/acpi/cppc_acpi.c +0 -0
index 0bbf84b..8ca4c2c 100644

drivers/acpi/cppc_acpi.c int acpi_cppc_processor_probe(struct acpi_processor *pr) · line 529

Quoted 7 lines
drivers/acpi/cppc_acpi.c +0 -1
@@ -524,7 +524,6 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
 	return 0;
 
 out_free:
-	cpc_ptr = per_cpu(cpc_desc_ptr, pr->id);
 	kfree(cpc_ptr);
 
 out_buf_free:

Applied, thanks!

Rafael