Skip to contentSkip to conversation

drivers:media: Add proper sanity checking for register setting to variable in lg2160.c

PATCH Michael Ira Krufky 1 participant 1 message Nov 30, 2014 1 message not in the archive Media (V4L/DVB)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 25 lines · Nicholas Krause

Fixs issue with setting the variable value of val in the functionm,lg2161_set_output_interface and not sanity checking if the value has been correctly set with the correct value of the struct state of type lg216x_state passed to the function by the calling code.

---
 drivers/media/dvb-frontends/lg2160.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/dvb-frontends/lg2160.c +3 -2
index 5fd14f8..9aec63a 100644
@@ -459,7 +459,9 @@ static int lg2161_set_output_interface(struct lg216x_state *state)
                goto fail;
 
        val &= ~0x07;
-       val |= state->cfg->output_if; /* FIXME: needs sanity check */
+       val |= state->cfg->output_if;
+       if (lg_fail(val))
+               goto fail;
 
        ret = lg216x_write_reg(state, 0x0014, val);
        lg_fail(ret);
--
Quoted 2 lines

2.1.0

NACK.

Thank you for the patch, Nicholas, but the change that you propose won't actually help here -- val is a u8, and the lg_fail() macro tests for negative values. val can never be negative, and that's why I didn't add the "lg_fail()" test myself when I wrote this function.

What's actually happening in this function is that the value is first set when reading register 0014, we take that value, unset the three lowest bits, then we raise the bits in state->cfg->output_if, and write it back to the same register.

In fact, the FIXME comment should be removed -- this is not a bug anymore and the sanity check is built-in. That FIXME comment is a remnant of an older version of this function :-P

If you want to send a patch that just removes the FIXME comment, that would be accepted, but this patch should not be merged.

Cheers,

Michael Ira Krufky