]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.29/powerpc-nvram-fix-an-incorrect-partition-merge.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.29 / powerpc-nvram-fix-an-incorrect-partition-merge.patch
1 From 11b7e154b132232535befe51c55db048069c8461 Mon Sep 17 00:00:00 2001
2 From: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
3 Date: Thu, 10 Dec 2015 15:30:02 +0800
4 Subject: powerpc/nvram: Fix an incorrect partition merge
5
6 From: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
7
8 commit 11b7e154b132232535befe51c55db048069c8461 upstream.
9
10 When we merge two contiguous partitions whose signatures are marked
11 NVRAM_SIG_FREE, We need update prev's length and checksum, then write it
12 to nvram, not cur's. So lets fix this mistake now.
13
14 Also use memset instead of strncpy to set the partition's name. It's
15 more readable if we want to fill up with duplicate chars .
16
17 Fixes: fa2b4e54d41f ("powerpc/nvram: Improve partition removal")
18 Signed-off-by: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
19 Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21
22 ---
23 arch/powerpc/kernel/nvram_64.c | 6 +++---
24 1 file changed, 3 insertions(+), 3 deletions(-)
25
26 --- a/arch/powerpc/kernel/nvram_64.c
27 +++ b/arch/powerpc/kernel/nvram_64.c
28 @@ -969,7 +969,7 @@ int __init nvram_remove_partition(const
29
30 /* Make partition a free partition */
31 part->header.signature = NVRAM_SIG_FREE;
32 - strncpy(part->header.name, "wwwwwwwwwwww", 12);
33 + memset(part->header.name, 'w', 12);
34 part->header.checksum = nvram_checksum(&part->header);
35 rc = nvram_write_header(part);
36 if (rc <= 0) {
37 @@ -987,8 +987,8 @@ int __init nvram_remove_partition(const
38 }
39 if (prev) {
40 prev->header.length += part->header.length;
41 - prev->header.checksum = nvram_checksum(&part->header);
42 - rc = nvram_write_header(part);
43 + prev->header.checksum = nvram_checksum(&prev->header);
44 + rc = nvram_write_header(prev);
45 if (rc <= 0) {
46 printk(KERN_ERR "nvram_remove_partition: nvram_write failed (%d)\n", rc);
47 return rc;