Commit 29b301d2 authored by Pan Xinhui's avatar Pan Xinhui Committed by Luis Henriques

powerpc/nvram: Fix an incorrect partition merge

BugLink: http://bugs.launchpad.net/bugs/1638267

commit 11b7e154 upstream.

When we merge two contiguous partitions whose signatures are marked
NVRAM_SIG_FREE, We need update prev's length and checksum, then write it
to nvram, not cur's. So lets fix this mistake now.

Also use memset instead of strncpy to set the partition's name. It's
more readable if we want to fill up with duplicate chars .

Fixes: fa2b4e54 ("powerpc/nvram: Improve partition removal")
Signed-off-by: default avatarPan Xinhui <xinhui.pan@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
parent f928a88e
...@@ -969,7 +969,7 @@ int __init nvram_remove_partition(const char *name, int sig, ...@@ -969,7 +969,7 @@ int __init nvram_remove_partition(const char *name, int sig,
/* Make partition a free partition */ /* Make partition a free partition */
part->header.signature = NVRAM_SIG_FREE; part->header.signature = NVRAM_SIG_FREE;
strncpy(part->header.name, "wwwwwwwwwwww", 12); memset(part->header.name, 'w', 12);
part->header.checksum = nvram_checksum(&part->header); part->header.checksum = nvram_checksum(&part->header);
rc = nvram_write_header(part); rc = nvram_write_header(part);
if (rc <= 0) { if (rc <= 0) {
...@@ -987,8 +987,8 @@ int __init nvram_remove_partition(const char *name, int sig, ...@@ -987,8 +987,8 @@ int __init nvram_remove_partition(const char *name, int sig,
} }
if (prev) { if (prev) {
prev->header.length += part->header.length; prev->header.length += part->header.length;
prev->header.checksum = nvram_checksum(&part->header); prev->header.checksum = nvram_checksum(&prev->header);
rc = nvram_write_header(part); rc = nvram_write_header(prev);
if (rc <= 0) { if (rc <= 0) {
printk(KERN_ERR "nvram_remove_partition: nvram_write failed (%d)\n", rc); printk(KERN_ERR "nvram_remove_partition: nvram_write failed (%d)\n", rc);
return rc; return rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment