All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lenny Szubowicz <lszubowi@redhat.com>
To: tony.luck@intel.com, cbouatmailru@gmail.com,
	matt.fleming@intel.com, linux-kernel@vger.kernel.org
Cc: n.hamaguchi@jp.fujitsu.com, dzickus@redhat.com
Subject: [PATCH 3/3] efivars: If pstore_register fails, free unneeded pstore buffer
Date: Fri, 28 Jun 2013 16:14:11 -0400	[thread overview]
Message-ID: <1372450451-8790-4-git-send-email-lszubowi@redhat.com> (raw)
In-Reply-To: <1372450451-8790-1-git-send-email-lszubowi@redhat.com>

This is patch 3/3 of a patch set that cleans up pstore_register failure paths.

If efivars fails to register with pstore, there is no point to keeping
the 4 KB buffer around. It's only used by the pstore read/write routines.

Signed-off-by: Lenny Szubowicz <lszubowi@redhat.com>
Reported-by: Naotaka Hamaguchi <n.hamaguchi@jp.fujitsu.com>
---
 drivers/firmware/efi/efi-pstore.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index 202d2c8..66c0c76 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -236,7 +236,11 @@ static __init int efivars_pstore_init(void)
 	efi_pstore_info.bufsize = 1024;
 	spin_lock_init(&efi_pstore_info.buf_lock);
 
-	pstore_register(&efi_pstore_info);
+	if (pstore_register(&efi_pstore_info)) {
+		kfree(efi_pstore_info.buf);
+		efi_pstore_info.buf = NULL;
+		efi_pstore_info.bufsize = 0;
+	}
 
 	return 0;
 }
-- 
1.8.2.1


  parent reply	other threads:[~2013-06-28 20:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-28 20:14 [PATCH 0/3] acpi: Eliminate misleading erst pstore console message Lenny Szubowicz
2013-06-28 20:14 ` [PATCH 1/3] pstore: Return unique error if backend registration excluded by kernel param Lenny Szubowicz
2013-06-28 20:14 ` [PATCH 2/3] acpi: Eliminate console msg if pstore.backend excludes ERST Lenny Szubowicz
2013-06-28 20:44   ` Tony Luck
2013-06-28 20:57     ` Lenny Szubowicz
2013-06-28 20:14 ` Lenny Szubowicz [this message]
2013-06-28 22:42 ` [PATCH 0/3] acpi: Eliminate misleading erst pstore console message Tony Luck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1372450451-8790-4-git-send-email-lszubowi@redhat.com \
    --to=lszubowi@redhat.com \
    --cc=cbouatmailru@gmail.com \
    --cc=dzickus@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt.fleming@intel.com \
    --cc=n.hamaguchi@jp.fujitsu.com \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.