Skip to content

Commit 1d286b1

Browse files
HatsyReiGratian Crisan
authored andcommitted
mtd: Create gluebi mtdblocks if CONFIG_FTL is not enabled
Upstream commit a43bdc3 ("mtd: Fix gluebi NULL pointer dereference caused by ftl notifier") fixed a NULL pointer dereference, which can be caused by FTL notifier accessing 'gluebi->desc' in gluebi_read, by completely preventing gluebi from creating mtdblock devices. This creates a problem as existing systems may expect mtdblocks emulated on top of UBI to exist. As a workaround, this commit prevents gluebi mtdblock device creation only if CONFIG_FTL is enabled. Signed-off-by: HatsyRei <yan.huan.chng@emerson.com> [gratian: reword to match commit quoting kernel standard] Signed-off-by: Gratian Crisan <gratian.crisan@emerson.com>
1 parent 76c9aec commit 1d286b1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/mtd/mtd_blkdevs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ static void blktrans_notify_add(struct mtd_info *mtd)
463463
{
464464
struct mtd_blktrans_ops *tr;
465465

466-
if (mtd->type == MTD_ABSENT || mtd->type == MTD_UBIVOLUME)
466+
if (mtd->type == MTD_ABSENT ||
467+
(IS_ENABLED(CONFIG_FTL) && mtd->type == MTD_UBIVOLUME))
467468
return;
468469

469470
list_for_each_entry(tr, &blktrans_majors, list)
@@ -503,7 +504,8 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
503504
mutex_lock(&mtd_table_mutex);
504505
list_add(&tr->list, &blktrans_majors);
505506
mtd_for_each_device(mtd)
506-
if (mtd->type != MTD_ABSENT && mtd->type != MTD_UBIVOLUME)
507+
if (mtd->type != MTD_ABSENT &&
508+
!(IS_ENABLED(CONFIG_FTL) && mtd->type == MTD_UBIVOLUME))
507509
tr->add_mtd(tr, mtd);
508510
mutex_unlock(&mtd_table_mutex);
509511
return 0;

0 commit comments

Comments
 (0)