Return-Path: Message-Id: <20130325010534.602354282@decadent.org.uk> Date: Mon, 25 Mar 2013 01:07:08 +0000 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: akpm@linux-foundation.org Subject: [ 104/104] efivars: pstore: Do not check size when erasing variable Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In-Reply-To: <20130325010524.240972766@decadent.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: 3.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ben Hutchings In 3.2, unlike mainline, efi_pstore_erase() calls efi_pstore_write() with a size of 0, as the underlying EFI interface treats a size of 0 as meaning deletion. This was not taken into account in my backport of commit d80a361d779a 'efi_pstore: Check remaining space with QueryVariableInfo() before writing data'. The size check should be omitted when erasing. Signed-off-by: Ben Hutchings --- --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c @@ -787,19 +787,21 @@ static int efi_pstore_write(enum pstore_ spin_lock_irqsave(&efivars->lock, flags); - /* - * Check if there is a space enough to log. - * size: a size of logging data - * DUMP_NAME_LEN * 2: a maximum size of variable name - */ + if (size) { + /* + * Check if there is a space enough to log. + * size: a size of logging data + * DUMP_NAME_LEN * 2: a maximum size of variable name + */ - status = check_var_size_locked(efivars, PSTORE_EFI_ATTRIBUTES, - size + DUMP_NAME_LEN * 2); + status = check_var_size_locked(efivars, PSTORE_EFI_ATTRIBUTES, + size + DUMP_NAME_LEN * 2); - if (status) { - spin_unlock_irqrestore(&efivars->lock, flags); - *id = part; - return -ENOSPC; + if (status) { + spin_unlock_irqrestore(&efivars->lock, flags); + *id = part; + return -ENOSPC; + } } for (i = 0; i < DUMP_NAME_LEN; i++)