MTD Fixes:
- Fix a bug introduced when exposing MTD devs as NVMEM providers and check for add_mtd_device() return code everywhere raw NAND fixes: - Fix a memory corruption in the QCOM driver -----BEGIN PGP SIGNATURE----- iQJKBAABCgA0FiEEKmCqpbOU668PNA69Ze02AX4ItwAFAlw3AH4WHGJicmV6aWxs b25Aa2VybmVsLm9yZwAKCRBl7TYBfgi3AEbeEACdjuGgEh7rbfa1Chmi8UDZ3mUY FjZ29AV6u+NLHLqh5CGMCxmn0PT4EpZmd31YK9Lyxr9LTP+MU0mEBbqaHSwLmGOx O7bSL7Wjz6tJEfejSd/hfEohgqqXQNl9CnI0wxA6vLlkMmWsO8YzyiPf3DtkXsg+ VWu6W1HGvjAzz4dcUGgDIEXUrns/DuMOUfsLvhGvM8HJVyrLyHiV5IZnP7eKOqPv 9w6oxhPa+NR7Ki3GZ/vN1fPAn9mkG7nx1xPiVjW9pgkTFnsfciUHx6XRalJpIRON fLsAiRTyRIqhpfdcIdY9KoizcsCVmXKEDJ+KvWFl914sCqMY2vhMWN5uYcYLmwgj GHllBLT4u2mizGIry+9MitT9OewY71P3hVdF2bIRpgVEqLrsW2B4KqctAsH8aLL7 fpPMO9FIYlL3VKu2jAuLxxqsXNa2L6I6ZhCcb/Fh2tXx6SHeLCaaYsFHg93AJxex vU3nfS+CfQzzXATmzNJZhVAGh2pNB/Bqv7y9/p50hnJri421+6Jp9f7P9KTuFQan 1CCMxNYHZgGecBGirufhTC4SS/EFGS0VTepe8c83NAZ2F7y/KTb1D/LBrgdjUDWy pQq9UsepkFML42RNqaGYRzgMESHWwbW/o6BIu9rsvalRDIW+06cU14Zo4Ndi9Cbj 0lFNjl9st8yyJ/yX7Q== =dFzQ -----END PGP SIGNATURE----- Merge tag 'mtd/fixes-for-5.0-rc2' of git://git.infradead.org/linux-mtd Pull mtd fixes from Boris Brezillon: "Core MTD Fixes: - Fix a bug introduced when exposing MTD devs as NVMEM providers and check for add_mtd_device() return code everywhere raw NAND fixes: - Fix a memory corruption in the QCOM driver" * tag 'mtd/fixes-for-5.0-rc2' of git://git.infradead.org/linux-mtd: mtd: rawnand: qcom: fix memory corruption that causes panic mtd: Check add_mtd_device() ret code mtd: Fix the check on nvmem_register() ret code
This commit is contained in:
commit
e7446be446
@ -522,7 +522,7 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
|
||||
mtd->nvmem = nvmem_register(&config);
|
||||
if (IS_ERR(mtd->nvmem)) {
|
||||
/* Just ignore if there is no NVMEM support in the kernel */
|
||||
if (PTR_ERR(mtd->nvmem) == -ENOSYS) {
|
||||
if (PTR_ERR(mtd->nvmem) == -EOPNOTSUPP) {
|
||||
mtd->nvmem = NULL;
|
||||
} else {
|
||||
dev_err(&mtd->dev, "Failed to register NVMEM device\n");
|
||||
|
@ -7,7 +7,7 @@
|
||||
extern struct mutex mtd_table_mutex;
|
||||
|
||||
struct mtd_info *__mtd_next_device(int i);
|
||||
int add_mtd_device(struct mtd_info *mtd);
|
||||
int __must_check add_mtd_device(struct mtd_info *mtd);
|
||||
int del_mtd_device(struct mtd_info *mtd);
|
||||
int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
|
||||
int del_mtd_partitions(struct mtd_info *);
|
||||
|
@ -618,10 +618,22 @@ int mtd_add_partition(struct mtd_info *parent, const char *name,
|
||||
list_add(&new->list, &mtd_partitions);
|
||||
mutex_unlock(&mtd_partitions_mutex);
|
||||
|
||||
add_mtd_device(&new->mtd);
|
||||
ret = add_mtd_device(&new->mtd);
|
||||
if (ret)
|
||||
goto err_remove_part;
|
||||
|
||||
mtd_add_partition_attrs(new);
|
||||
|
||||
return 0;
|
||||
|
||||
err_remove_part:
|
||||
mutex_lock(&mtd_partitions_mutex);
|
||||
list_del(&new->list);
|
||||
mutex_unlock(&mtd_partitions_mutex);
|
||||
|
||||
free_partition(new);
|
||||
pr_info("%s:%i\n", __func__, __LINE__);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_add_partition);
|
||||
@ -712,22 +724,31 @@ int add_mtd_partitions(struct mtd_info *master,
|
||||
{
|
||||
struct mtd_part *slave;
|
||||
uint64_t cur_offset = 0;
|
||||
int i;
|
||||
int i, ret;
|
||||
|
||||
printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);
|
||||
|
||||
for (i = 0; i < nbparts; i++) {
|
||||
slave = allocate_partition(master, parts + i, i, cur_offset);
|
||||
if (IS_ERR(slave)) {
|
||||
del_mtd_partitions(master);
|
||||
return PTR_ERR(slave);
|
||||
ret = PTR_ERR(slave);
|
||||
goto err_del_partitions;
|
||||
}
|
||||
|
||||
mutex_lock(&mtd_partitions_mutex);
|
||||
list_add(&slave->list, &mtd_partitions);
|
||||
mutex_unlock(&mtd_partitions_mutex);
|
||||
|
||||
add_mtd_device(&slave->mtd);
|
||||
ret = add_mtd_device(&slave->mtd);
|
||||
if (ret) {
|
||||
mutex_lock(&mtd_partitions_mutex);
|
||||
list_del(&slave->list);
|
||||
mutex_unlock(&mtd_partitions_mutex);
|
||||
|
||||
free_partition(slave);
|
||||
goto err_del_partitions;
|
||||
}
|
||||
|
||||
mtd_add_partition_attrs(slave);
|
||||
/* Look for subpartitions */
|
||||
parse_mtd_partitions(&slave->mtd, parts[i].types, NULL);
|
||||
@ -736,6 +757,11 @@ int add_mtd_partitions(struct mtd_info *master,
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_del_partitions:
|
||||
del_mtd_partitions(master);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static DEFINE_SPINLOCK(part_parser_lock);
|
||||
|
@ -2833,6 +2833,16 @@ static int qcom_nand_host_init_and_register(struct qcom_nand_controller *nandc,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (nandc->props->is_bam) {
|
||||
free_bam_transaction(nandc);
|
||||
nandc->bam_txn = alloc_bam_transaction(nandc);
|
||||
if (!nandc->bam_txn) {
|
||||
dev_err(nandc->dev,
|
||||
"failed to allocate bam transaction\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
ret = mtd_device_register(mtd, NULL, 0);
|
||||
if (ret)
|
||||
nand_cleanup(chip);
|
||||
@ -2847,16 +2857,6 @@ static int qcom_probe_nand_devices(struct qcom_nand_controller *nandc)
|
||||
struct qcom_nand_host *host;
|
||||
int ret;
|
||||
|
||||
if (nandc->props->is_bam) {
|
||||
free_bam_transaction(nandc);
|
||||
nandc->bam_txn = alloc_bam_transaction(nandc);
|
||||
if (!nandc->bam_txn) {
|
||||
dev_err(nandc->dev,
|
||||
"failed to allocate bam transaction\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
for_each_available_child_of_node(dn, child) {
|
||||
host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL);
|
||||
if (!host) {
|
||||
|
Loading…
Reference in New Issue
Block a user