media: vidtv: fix pass-by-value structs causing MSAN warnings
Subsystems (2)
PATCH v2 1/1 media: vidtv: fix pass-by-value structs causing MSAN warnings
vidtv_ts_null_write_into() and vidtv_ts_pcr_write_into() take their argument structs by value, causing MSAN to report uninit-value warnings. While only vidtv_ts_null_write_into() has triggered a report so far, both functions share the same issue.
Fix by passing both structs by const pointer instead, avoiding the stack copy of the struct along with its MSAN shadow and origin metadata. The functions do not modify the structs, which is enforced by the const qualifier.
---
Changes in v2:
- Fix the incorrect 'Fixes' tag
- Add const qualifier to function parameters
- Fix a similar pass-by-value issue in vidtv_ts_pcr_write_into()
- Link to v1: https://lore.kernel.org/all/[email protected]/
--- drivers/media/test-drivers/vidtv/vidtv_mux.c | 4 +- drivers/media/test-drivers/vidtv/vidtv_ts.c | 48 ++++++++++---------- drivers/media/test-drivers/vidtv/vidtv_ts.h | 4 +- 3 files changed, 28 insertions(+), 28 deletions(-)
drivers/media/test-drivers/vidtv/vidtv_mux.c +2 -2
@@ -233,7 +233,7 @@ static u32 vidtv_mux_push_pcr(struct vidtv_mux *m)/* the 27Mhz clock will feed both parts of the PCR bitfield */ args.pcr = m->timing.clk; - nbytes +=vidtv_ts_pcr_write_into (args); + nbytes +=vidtv_ts_pcr_write_into (&args); m->mux_buf_offset += nbytes; m->num_streamed_pcr++;
@@ -363,7 +363,7 @@ static u32 vidtv_mux_pad_with_nulls(struct vidtv_mux *m, u32 npkts) args.continuity_counter = &ctx->cc;for (i =0 ; i < npkts; ++i) { - m->mux_buf_offset +=vidtv_ts_null_write_into (args); + m->mux_buf_offset +=vidtv_ts_null_write_into (&args); args.dest_offset = m->mux_buf_offset; }
drivers/media/test-drivers/vidtv/vidtv_ts.c +24 -24
96 lines not on this page · raw message
drivers/media/test-drivers/vidtv/vidtv_ts.h +2 -2
@@ -90,7 +90,7 @@ void vidtv_ts_inc_cc(u8 *continuity_counter);* * Return: The number of bytes written into the buffer. */ -u32 vidtv_ts_null_write_into (struct null_packet_write_args args); +u32 vidtv_ts_null_write_into (const struct null_packet_write_args *args);/** * vidtv_ts_pcr_write_into - Write a PCR packet into a buffer.
@@ -101,6 +101,6 @@ u32 vidtv_ts_null_write_into(struct null_packet_write_args args);* * Return: The number of bytes written into the buffer. */ -u32 vidtv_ts_pcr_write_into (struct pcr_write_args args); +u32 vidtv_ts_pcr_write_into (const struct pcr_write_args *args);#endif //VIDTV_TS_H
Signature · 1 line
2.51.0
Daniel Almeida
maintainerHi there, thanks for your contribution.
Quoted 12 lines · Abd-Alrhman Masalkhi
vidtv_ts_null_write_into()andvidtv_ts_pcr_write_into()take their argument structs by value, causing MSAN to report uninit-value warnings. While onlyvidtv_ts_null_write_into()has triggered a report so far, both functions share the same issue.Fix by passing both structs by const pointer instead, avoiding the stack copy of the struct along with its MSAN shadow and origin metadata. The functions do not modify the structs, which is enforced by the const qualifier.
Quoted 7 lines
Fixes f90cf6079bf67 ("media: vidtv: add a bridge driver")Reported-by [email protected]Tested-by [email protected]Suggested-by Yihan Ding <[email protected]>Signed-off-by Abd-Alrhman Masalkhi <[email protected]>—
I will eventually get to this patch.
— Daniel