block: precedence bug in bio_set_op_attrs() macro
Subsystems (3)
PATCH 1/1 block: precedence bug in bio_set_op_attrs() macro
This code causes a problem for flush_epd_write_bio() because | has higher precedence than ?: so it basically turns into:
((bio)->bi_opf |= REQ_SYNC;
Which is wrong.
Fixes ef295ecf090d ("block: better op and flags encoding")
Signed-off-by Dan Carpenter <[email protected]>
include/linux/blk_types.h +1 -1
@@ -208,7 +208,7 @@ enum req_flag_bits {/* obsolete, don't use in new code */ #define bio_set_op_attrs (bio, op, op_flags) \ - ((bio)->bi_opf |= (op | op_flags)) + ((bio)->bi_opf |= ((op) | (op_flags)))static inline bool op_is_write (unsigned int op) {
Quoted 6 lines · Dan Carpenter
This code causes a problem for
flush_epd_write_bio()because | has higher precedence than ?: so it basically turns into:((bio)->bi_opf |= REQ_SYNC;Which is wrong.
Its is. And while we're at it the macro should really be doing a = instead of |=.
And we really should stop using it, at least in the block core even ASAP.