linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] acpi/apei: free lists of resources in einj and erst
@ 2015-07-10 11:58 Konstantin Khlebnikov
  2015-07-10 18:14 ` Luck, Tony
  0 siblings, 1 reply; 3+ messages in thread
From: Konstantin Khlebnikov @ 2015-07-10 11:58 UTC (permalink / raw)
  To: linux-acpi, Chen, Gong; +Cc: Tony Luck, linux-kernel, Tomasz Nowicki

This patch adds missing apei_resources_fini and
plugs several tiny memory leaks.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
 drivers/acpi/apei/apei-base.c |    2 ++
 drivers/acpi/apei/einj.c      |    7 +++----
 drivers/acpi/apei/erst.c      |    1 +
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index a85ac07f3da3..b9a5418e6938 100644
--- a/drivers/acpi/apei/apei-base.c
+++ b/drivers/acpi/apei/apei-base.c
@@ -497,6 +497,7 @@ int apei_resources_request(struct apei_resources *resources,
 	rc = apei_resources_sub(resources, &nvs_resources);
 	if (rc)
 		goto nvs_res_fini;
+	apei_resources_fini(&nvs_resources);
 
 	if (arch_apei_filter_addr) {
 		apei_resources_init(&arch_res);
@@ -506,6 +507,7 @@ int apei_resources_request(struct apei_resources *resources,
 		rc = apei_resources_sub(resources, &arch_res);
 		if (rc)
 			goto arch_res_fini;
+		apei_resources_fini(&arch_res);
 	}
 
 	rc = -EINVAL;
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index a095d4f858da..ed02d9da4a3e 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -379,10 +379,9 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
 			rc = apei_resources_add(&addr_resources,
 				trigger_param_region->address,
 				trigger_param_region->bit_width/8, true);
-			if (rc)
-				goto out_fini;
-			rc = apei_resources_sub(&trigger_resources,
-					&addr_resources);
+			if (!rc)
+				rc = apei_resources_sub(&trigger_resources,
+							&addr_resources);
 		}
 		apei_resources_fini(&addr_resources);
 		if (rc)
diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c
index 3670bbab57a3..41ceeae3f6aa 100644
--- a/drivers/acpi/apei/erst.c
+++ b/drivers/acpi/apei/erst.c
@@ -1190,6 +1190,7 @@ static int __init erst_init(void)
 	if (!erst_erange.vaddr)
 		goto err_release_erange;
 
+	apei_resources_fini(&erst_resources);
 	pr_info(
 	"Error Record Serialization Table (ERST) support is initialized.\n");
 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] acpi/apei: free lists of resources in einj and erst
  2015-07-10 11:58 [PATCH] acpi/apei: free lists of resources in einj and erst Konstantin Khlebnikov
@ 2015-07-10 18:14 ` Luck, Tony
  2015-07-13  9:43   ` Konstantin Khlebnikov
  0 siblings, 1 reply; 3+ messages in thread
From: Luck, Tony @ 2015-07-10 18:14 UTC (permalink / raw)
  To: Konstantin Khlebnikov, linux-acpi@vger.kernel.org, Chen, Gong
  Cc: linux-kernel@vger.kernel.org, Tomasz Nowicki

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 837 bytes --]

--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -379,10 +379,9 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
 			rc = apei_resources_add(&addr_resources,
 				trigger_param_region->address,
 				trigger_param_region->bit_width/8, true);
-			if (rc)
-				goto out_fini;
-			rc = apei_resources_sub(&trigger_resources,
-					&addr_resources);
+			if (!rc)
+				rc = apei_resources_sub(&trigger_resources,
+							&addr_resources);
 		}
 		apei_resources_fini(&addr_resources);
 		if (rc)

This bit looks wrong ... the line right after the this diff ends is
			goto out_fini;

so we'll call apei_resources_fini() twice in the rc!=0 case.

-Tony
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] acpi/apei: free lists of resources in einj and erst
  2015-07-10 18:14 ` Luck, Tony
@ 2015-07-13  9:43   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 3+ messages in thread
From: Konstantin Khlebnikov @ 2015-07-13  9:43 UTC (permalink / raw)
  To: Luck, Tony
  Cc: Konstantin Khlebnikov, linux-acpi@vger.kernel.org, Chen, Gong,
	linux-kernel@vger.kernel.org, Tomasz Nowicki

On Fri, Jul 10, 2015 at 9:14 PM, Luck, Tony <tony.luck@intel.com> wrote:
> --- a/drivers/acpi/apei/einj.c
> +++ b/drivers/acpi/apei/einj.c
> @@ -379,10 +379,9 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
>                         rc = apei_resources_add(&addr_resources,
>                                 trigger_param_region->address,
>                                 trigger_param_region->bit_width/8, true);
> -                       if (rc)
> -                               goto out_fini;
> -                       rc = apei_resources_sub(&trigger_resources,
> -                                       &addr_resources);
> +                       if (!rc)
> +                               rc = apei_resources_sub(&trigger_resources,
> +                                                       &addr_resources);
>                 }
>                 apei_resources_fini(&addr_resources);
>                 if (rc)
>
> This bit looks wrong ... the line right after the this diff ends is
>                         goto out_fini;
>
> so we'll call apei_resources_fini() twice in the rc!=0 case.

As I see it frees different struct apei_resources: here addr_resources and
trigger_resources at the out_fini.

Anyway calling apei_resources_fini twice is safe: it removes and frees ranges
from lists. If these lists are empty apei_resources_fini does nothing.

>
> -Tony

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-13  9:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-10 11:58 [PATCH] acpi/apei: free lists of resources in einj and erst Konstantin Khlebnikov
2015-07-10 18:14 ` Luck, Tony
2015-07-13  9:43   ` Konstantin Khlebnikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).