]> git.ipfire.org Git - people/arne_f/kernel.git/commit
mtd: mtdconcat: Check _read, _write callbacks existence before assignment
authorZhihao Cheng <chengzhihao1@huawei.com>
Tue, 17 Aug 2021 11:48:57 +0000 (19:48 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Sep 2021 10:39:29 +0000 (12:39 +0200)
commit7655140eda8610850976695f14304f141aef4996
tree631b9f9c4b34356fe74d57a06954d7d754bdd1ee
parent5cd5c566aaf36c829c3e9656c86a752c398ed8c5
mtd: mtdconcat: Check _read, _write callbacks existence before assignment

[ Upstream commit a89d69a44e282be95ae76125dddc79515541efeb ]

Since 2431c4f5b46c3 ("mtd: Implement mtd_{read,write}() as wrappers
around mtd_{read,write}_oob()") don't allow _write|_read and
_write_oob|_read_oob existing at the same time, we should check the
existence of callbacks "_read and _write" from subdev's master device
(We can trust master device since it has been registered) before
assigning, otherwise following warning occurs while making
concatenated device:

  WARNING: CPU: 2 PID: 6728 at drivers/mtd/mtdcore.c:595
  add_mtd_device+0x7f/0x7b0

Fixes: 2431c4f5b46c3 ("mtd: Implement mtd_{read,write}() around ...")
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210817114857.2784825-3-chengzhihao1@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mtd/mtdconcat.c