Merge branch 'linux-next' of git://git.infradead.org/ubi-2.6

* 'linux-next' of git://git.infradead.org/ubi-2.6:
UBI: fix memory leak in update path
UBI: add more checks to chdev open
UBI: initialise update marker

+10 -9
+8 -9
drivers/mtd/ubi/kapi.c
··· 291 291 */ 292 292 struct ubi_volume_desc *ubi_open_volume_path(const char *pathname, int mode) 293 293 { 294 - int error, ubi_num, vol_id; 295 - struct ubi_volume_desc *ret; 294 + int error, ubi_num, vol_id, mod; 296 295 struct inode *inode; 297 296 struct path path; 298 297 ··· 305 306 return ERR_PTR(error); 306 307 307 308 inode = path.dentry->d_inode; 309 + mod = inode->i_mode; 308 310 ubi_num = ubi_major2num(imajor(inode)); 309 311 vol_id = iminor(inode) - 1; 310 - 311 - if (vol_id >= 0 && ubi_num >= 0) 312 - ret = ubi_open_volume(ubi_num, vol_id, mode); 313 - else 314 - ret = ERR_PTR(-ENODEV); 315 - 316 312 path_put(&path); 317 - return ret; 313 + 314 + if (!S_ISCHR(mod)) 315 + return ERR_PTR(-EINVAL); 316 + if (vol_id >= 0 && ubi_num >= 0) 317 + return ubi_open_volume(ubi_num, vol_id, mode); 318 + return ERR_PTR(-ENODEV); 318 319 } 319 320 EXPORT_SYMBOL_GPL(ubi_open_volume_path); 320 321
+1
drivers/mtd/ubi/upd.c
··· 155 155 if (err) 156 156 return err; 157 157 vol->updating = 0; 158 + return 0; 158 159 } 159 160 160 161 vol->upd_buf = vmalloc(ubi->leb_size);
+1
drivers/mtd/ubi/vtbl.c
··· 566 566 vol->reserved_pebs = be32_to_cpu(vtbl[i].reserved_pebs); 567 567 vol->alignment = be32_to_cpu(vtbl[i].alignment); 568 568 vol->data_pad = be32_to_cpu(vtbl[i].data_pad); 569 + vol->upd_marker = vtbl[i].upd_marker; 569 570 vol->vol_type = vtbl[i].vol_type == UBI_VID_DYNAMIC ? 570 571 UBI_DYNAMIC_VOLUME : UBI_STATIC_VOLUME; 571 572 vol->name_len = be16_to_cpu(vtbl[i].name_len);