md/raid1-10: shut up randstruct warning again
PATCH 1/1 md/raid1-10: shut up randstruct warning again
From: Arnd Bergmann <[email protected]>
A code reorganization brought back a warning when structure randomization is enabled:
drivers/md/raid1-10.c:119:25: error: casting from randomized structure pointer type 'struct block_device *' to 'struct md_rdev *'
struct md_rdev *rdev = (struct md_rdev *)bio->bi_bdev;
^Before the rework, this used a (void*) cast, so go back to that in order to avoid the warning. Casting between pointers to incompatible types is clearly something that is dangerous, but this driver has always done so, and it's not made any worse by the struct randomization in this case.
--- drivers/md/raid1-10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid1-10.c +1 -1
@@ -116,7 +116,7 @@ static void md_bio_reset_resync_pages(struct bio *bio, struct resync_pages *rp,static inline void raid1_submit_write (struct bio *bio) { -struct md_rdev *rdev = (struct md_rdev *)bio->bi_bdev; +struct md_rdev *rdev = (void *)bio->bi_bdev; bio->bi_next =NULL ;bio_set_dev (bio, rdev->bdev);
Signature · 1 line
2.39.2
Hi,
Quoted 9 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
A code reorganization brought back a warning when structure randomization is enabled:
drivers/md/raid1-10.c:119:25: error: casting from randomized structure pointer type 'structblock_device*' to 'structmd_rdev*'struct md_rdev *rdev = (struct md_rdev *)bio->bi_bdev; ^
Quoted 7 lines
Before the rework, this used a (void*) cast, so go back to that in order to avoid the warning. Casting between pointers to incompatible types is clearly something that is dangerous, but this driver has always done so, and it's not made any worse by the struct randomization in this case.
Fixes 8295efbe68c08 ("md/raid1-10: factor out a helper to submit normal write")Signed-off-by Arnd Bergmann <[email protected]>
Thanks for the patch, and this problem is already reported by kernel test robot:
https://lore.kernel.org/oe-kbuild-all/[email protected]/
And fixed patch is already applied:
https://lore.kernel.org/lkml/CAPhsuW6aSvCEa1khjjmDYGozUEs+Tx75RxfaE1+xL2Y1T6aN=Q@mail.gmail.com/T/
Thanks,
Kuai
Quoted 18 lines
--- drivers/md/raid1-10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/raid1-10.c +1
-1@@ -116,7 +116,7 @@ static void md_bio_reset_resync_pages(struct bio *bio, struct resync_pages *rp,static inline void raid1_submit_write (struct bio *bio) { -struct md_rdev *rdev = (struct md_rdev *)bio->bi_bdev; +struct md_rdev *rdev = (void *)bio->bi_bdev; bio->bi_next =NULL ;bio_set_dev (bio, rdev->bdev);