* [PATCH] ST_CORE: Error triggered by convert "char" to "int"
@ 2013-01-10 8:27 channing
2013-01-10 8:45 ` Liu, Chuansheng
0 siblings, 1 reply; 2+ messages in thread
From: channing @ 2013-01-10 8:27 UTC (permalink / raw)
To: alan, gregkh, akpm, pavan_savoy; +Cc: chuansheng.liu, linux-kernel
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: channing <chao.bi@intel.com>
---
drivers/misc/ti-st/st_core.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
index b90a224..0a14280 100644
--- a/drivers/misc/ti-st/st_core.c
+++ b/drivers/misc/ti-st/st_core.c
@@ -240,7 +240,8 @@ void st_int_recv(void *disc_data,
char *ptr;
struct st_proto_s *proto;
unsigned short payload_len = 0;
- int len = 0, type = 0;
+ int len = 0;
+ unsigned char type = 0;
unsigned char *plen;
struct st_data_s *st_gdata = (struct st_data_s *)disc_data;
unsigned long flags;
--
1.7.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [PATCH] ST_CORE: Error triggered by convert "char" to "int"
2013-01-10 8:27 [PATCH] ST_CORE: Error triggered by convert "char" to "int" channing
@ 2013-01-10 8:45 ` Liu, Chuansheng
0 siblings, 0 replies; 2+ messages in thread
From: Liu, Chuansheng @ 2013-01-10 8:45 UTC (permalink / raw)
To: Bi, Chao, alan, gregkh, akpm, pavan_savoy; +Cc: linux-kernel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1367 bytes --]
> -----Original Message-----
> From: Bi, Chao
> Sent: Thursday, January 10, 2013 4:27 PM
> To: alan@linux.intel.com; gregkh@linuxfoundation.org;
> akpm@linux-foundation.org; pavan_savoy@ti.com
> Cc: Liu, Chuansheng; linux-kernel@vger.kernel.org
> Subject: [PATCH] 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.
>
Some infos:
when the type is minus, it will cause panic, because the below code
just consider type >= ST_MAX_CHANNELS case, no type < 0 case,
but it really happened.
if ((type >= ST_MAX_CHANNELS) ||
(st_gdata->list[type] == NULL)) {
Changing type from int to unsigned char can get benefit from the above
code.
If possible:
Acked-by: liu chuansheng <chuansheng.liu@intel.com>
Thanks.
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-10 8:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-10 8:27 [PATCH] ST_CORE: Error triggered by convert "char" to "int" channing
2013-01-10 8:45 ` Liu, Chuansheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®