Commit 1260662f authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Jiri Kosina

HID: intel_ish-hid: fix potential uninitialized data usage

gcc points out an uninialized pointer dereference that could happen
if we ever get to recv_ishtp_cl_msg_dma() or recv_ishtp_cl_msg()
with an empty &dev->read_list:

drivers/hid/intel-ish-hid/ishtp/client.c: In function 'recv_ishtp_cl_msg_dma':
drivers/hid/intel-ish-hid/ishtp/client.c:1049:3: error: 'cl' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The warning only appeared in very few randconfig builds, as the
spinlocks tend to prevent gcc from tracing the variables. I only
saw it in configurations that had neither SMP nor LOCKDEP enabled.

As we can see, we only enter the case if 'complete_rb' is non-NULL,
and then 'cl' is known to point to complete_rb->cl. Adding another
initialization to the same pointer is harmless here and makes it
clear to the compiler that the behavior is well-defined.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 7af4c727
...@@ -925,6 +925,7 @@ void recv_ishtp_cl_msg(struct ishtp_device *dev, ...@@ -925,6 +925,7 @@ void recv_ishtp_cl_msg(struct ishtp_device *dev,
} }
if (complete_rb) { if (complete_rb) {
cl = complete_rb->cl;
getnstimeofday(&cl->ts_rx); getnstimeofday(&cl->ts_rx);
++cl->recv_msg_cnt_ipc; ++cl->recv_msg_cnt_ipc;
ishtp_cl_read_complete(complete_rb); ishtp_cl_read_complete(complete_rb);
...@@ -1045,6 +1046,7 @@ void recv_ishtp_cl_msg_dma(struct ishtp_device *dev, void *msg, ...@@ -1045,6 +1046,7 @@ void recv_ishtp_cl_msg_dma(struct ishtp_device *dev, void *msg,
} }
if (complete_rb) { if (complete_rb) {
cl = complete_rb->cl;
getnstimeofday(&cl->ts_rx); getnstimeofday(&cl->ts_rx);
++cl->recv_msg_cnt_dma; ++cl->recv_msg_cnt_dma;
ishtp_cl_read_complete(complete_rb); ishtp_cl_read_complete(complete_rb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment