OSDN Git Service

media: flexcop-i2c: get rid of KERN_CONT
authorMauro Carvalho Chehab <mchehab@s-opensource.com>
Mon, 23 Apr 2018 12:29:09 +0000 (08:29 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Fri, 4 May 2018 13:01:40 +0000 (09:01 -0400)
commit25d4affb0c62444354b080c5d8444a8a4b89cd96
tree8b285b08b9b2142644028d3512c54ff3c6e6ef30
parent366b401001df15e4f493a585ff94a7399d7fae07
media: flexcop-i2c: get rid of KERN_CONT

Coverity complains about werid stuff at the debug logic:

CID 113542 (#1 of 1): Out-of-bounds access (ARRAY_VS_SINGLETON)10.
callee_ptr_arith: Passing buf to function flexcop_i2c_write4
which uses it as an array. This might corrupt or misinterpret
adjacent memory locations.

Instead of directly addressing the issue there, let's rework at
the logic there.

On newer kernels, KERN_CONT does nothing, as the previous message
won't wait for a continuation. Also, both flexcop_i2c_read4() and
flexcop_i2c_write4(), called by it, will print stuff if (debug &4).

So, the way it is is too buggy.

There are two kinds of debug stuff there: deb_i2c() and a code hidden
under #ifdef DUMP_I2C_MESSAGES, with can't be selected without touching
the source code.

Also, if both debug & 0x4 and DUMP_I2C_MESSAGES, flexcop_i2c_request()
will emit two debug messages per call with different data,
with sounds messy.

Simplify it by getting rid of DUMP_I2C_MESSAGES and adding a new
flag to debug (0x40), and making the debug logic there more
consistent.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/common/b2c2/flexcop-i2c.c
drivers/media/common/b2c2/flexcop.c
drivers/media/common/b2c2/flexcop.h