Commit 25c22d5b authored by channing's avatar channing Committed by Greg Kroah-Hartman

misc: st_core: Error triggered by convert "char" to "int"

When st driver decodes protocol index received from raw data,
it does a value convert from "char" to "int". Because it's sign
extension from bit8 to bit32, the "int" value maybe minus, in
another word, the protocol index might be minus, but driver doesn't
filter such case and may continue access memory pointed by this
minus index.

This patch is to change the variable type of index from "int"
to "unsigned char", so that it avoids do such kind of type
conversion.

cc: liu chuansheng <chuansheng.liu@intel.com>
Signed-off-by: default avatarchanning <chao.bi@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 867ff988
...@@ -240,7 +240,8 @@ void st_int_recv(void *disc_data, ...@@ -240,7 +240,8 @@ void st_int_recv(void *disc_data,
char *ptr; char *ptr;
struct st_proto_s *proto; struct st_proto_s *proto;
unsigned short payload_len = 0; unsigned short payload_len = 0;
int len = 0, type = 0; int len = 0;
unsigned char type = 0;
unsigned char *plen; unsigned char *plen;
struct st_data_s *st_gdata = (struct st_data_s *)disc_data; struct st_data_s *st_gdata = (struct st_data_s *)disc_data;
unsigned long flags; unsigned long flags;
......
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