* [PATCH] mtd: fix 'part' field data corruption in mtd_info
@ 2022-04-17 18:46 Oleksandr Ocheretnyi
2022-04-21 7:35 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Oleksandr Ocheretnyi @ 2022-04-17 18:46 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
linux-mtd, linux-kernel
Cc: oocheret
Commit 46b5889cc2c5 ("mtd: implement proper partition handling")
started using "mtd_get_master_ofs()" in mtd callbacks to determine
memory offsets by means of 'part' field from mtd_info, what previously
was smashed accessing 'master' field in the mtd_set_dev_defaults() method.
That provides wrong offset what causes hardware access errors.
Just make 'part', 'master' as separate fields, rather than using
union type to avoid 'part' data corruption when mtd_set_dev_defaults()
is called.
Fixes: 46b5889cc2c5 ("mtd: implement proper partition handling")
Signed-off-by: Oleksandr Ocheretnyi <oocheret@cisco.com>
---
include/linux/mtd/mtd.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 88227044fc86..8a2c60235ebb 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -394,10 +394,8 @@ struct mtd_info {
/* List of partitions attached to this MTD device */
struct list_head partitions;
- union {
- struct mtd_part part;
- struct mtd_master master;
- };
+ struct mtd_part part;
+ struct mtd_master master;
};
static inline struct mtd_info *mtd_get_master(struct mtd_info *mtd)
--
2.26.2.Cisco
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: fix 'part' field data corruption in mtd_info
2022-04-17 18:46 [PATCH] mtd: fix 'part' field data corruption in mtd_info Oleksandr Ocheretnyi
@ 2022-04-21 7:35 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2022-04-21 7:35 UTC (permalink / raw)
To: Oleksandr Ocheretnyi, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, linux-mtd, linux-kernel
On Sun, 2022-04-17 at 18:46:47 UTC, Oleksandr Ocheretnyi wrote:
> Commit 46b5889cc2c5 ("mtd: implement proper partition handling")
> started using "mtd_get_master_ofs()" in mtd callbacks to determine
> memory offsets by means of 'part' field from mtd_info, what previously
> was smashed accessing 'master' field in the mtd_set_dev_defaults() method.
> That provides wrong offset what causes hardware access errors.
>
> Just make 'part', 'master' as separate fields, rather than using
> union type to avoid 'part' data corruption when mtd_set_dev_defaults()
> is called.
>
> Fixes: 46b5889cc2c5 ("mtd: implement proper partition handling")
> Signed-off-by: Oleksandr Ocheretnyi <oocheret@cisco.com>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.
Miquel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-21 7:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-17 18:46 [PATCH] mtd: fix 'part' field data corruption in mtd_info Oleksandr Ocheretnyi
2022-04-21 7:35 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).