diff options
author | Jeff Garzik <jeff@garzik.org> | 2007-01-24 02:14:25 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-01-24 02:14:25 -0500 |
commit | e47b207a5bcb73bb097f94d9fe364f50737b0eb2 (patch) | |
tree | 57389653c37d001de3a90655cb4172ba29199ce4 /drivers/mtd/redboot.c | |
parent | d344bff9c36db17dc4765215495aaa7212c1eb6c (diff) | |
parent | 419dd8378dfa32985672ab7927b4bc827f33b332 (diff) |
Merge branch 'master' into upstream-fixes
Diffstat (limited to 'drivers/mtd/redboot.c')
-rw-r--r-- | drivers/mtd/redboot.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c index 5b58523e4d4e..035cd9b0cc08 100644 --- a/drivers/mtd/redboot.c +++ b/drivers/mtd/redboot.c | |||
@@ -96,7 +96,19 @@ static int parse_redboot_partitions(struct mtd_info *master, | |||
96 | */ | 96 | */ |
97 | if (swab32(buf[i].size) == master->erasesize) { | 97 | if (swab32(buf[i].size) == master->erasesize) { |
98 | int j; | 98 | int j; |
99 | for (j = 0; j < numslots && buf[j].name[0] != 0xff; ++j) { | 99 | for (j = 0; j < numslots; ++j) { |
100 | |||
101 | /* A single 0xff denotes a deleted entry. | ||
102 | * Two of them in a row is the end of the table. | ||
103 | */ | ||
104 | if (buf[j].name[0] == 0xff) { | ||
105 | if (buf[j].name[1] == 0xff) { | ||
106 | break; | ||
107 | } else { | ||
108 | continue; | ||
109 | } | ||
110 | } | ||
111 | |||
100 | /* The unsigned long fields were written with the | 112 | /* The unsigned long fields were written with the |
101 | * wrong byte sex, name and pad have no byte sex. | 113 | * wrong byte sex, name and pad have no byte sex. |
102 | */ | 114 | */ |
@@ -110,6 +122,9 @@ static int parse_redboot_partitions(struct mtd_info *master, | |||
110 | } | 122 | } |
111 | } | 123 | } |
112 | break; | 124 | break; |
125 | } else { | ||
126 | /* re-calculate of real numslots */ | ||
127 | numslots = buf[i].size / sizeof(struct fis_image_desc); | ||
113 | } | 128 | } |
114 | } | 129 | } |
115 | if (i == numslots) { | 130 | if (i == numslots) { |
@@ -123,8 +138,13 @@ static int parse_redboot_partitions(struct mtd_info *master, | |||
123 | for (i = 0; i < numslots; i++) { | 138 | for (i = 0; i < numslots; i++) { |
124 | struct fis_list *new_fl, **prev; | 139 | struct fis_list *new_fl, **prev; |
125 | 140 | ||
126 | if (buf[i].name[0] == 0xff) | 141 | if (buf[i].name[0] == 0xff) { |
127 | continue; | 142 | if (buf[i].name[1] == 0xff) { |
143 | break; | ||
144 | } else { | ||
145 | continue; | ||
146 | } | ||
147 | } | ||
128 | if (!redboot_checksum(&buf[i])) | 148 | if (!redboot_checksum(&buf[i])) |
129 | break; | 149 | break; |
130 | 150 | ||
@@ -165,15 +185,13 @@ static int parse_redboot_partitions(struct mtd_info *master, | |||
165 | } | 185 | } |
166 | } | 186 | } |
167 | #endif | 187 | #endif |
168 | parts = kmalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL); | 188 | parts = kzalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL); |
169 | 189 | ||
170 | if (!parts) { | 190 | if (!parts) { |
171 | ret = -ENOMEM; | 191 | ret = -ENOMEM; |
172 | goto out; | 192 | goto out; |
173 | } | 193 | } |
174 | 194 | ||
175 | memset(parts, 0, sizeof(*parts)*nrparts + nulllen + namelen); | ||
176 | |||
177 | nullname = (char *)&parts[nrparts]; | 195 | nullname = (char *)&parts[nrparts]; |
178 | #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED | 196 | #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED |
179 | if (nulllen > 0) { | 197 | if (nulllen > 0) { |