Commit 53d785cc authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

TTY: snyclinkmp: forever loop in tx_load_dma_buffer()

My main concern here was the line that said:
	copy_count = min_t(unsigned short,count,SCABUFSIZE);
"count" is an unsigned int here so the cast to unsigned short
truncates the upper bits.  So if count is 0x10000 then copy_count is
0 and the loop never exits.

"count" comes from skb->len in hdlcdev_xmit().

The other min_t() changes are just cleanups.
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 268e526b
...@@ -4950,7 +4950,7 @@ static bool rx_get_frame(SLMP_INFO *info) ...@@ -4950,7 +4950,7 @@ static bool rx_get_frame(SLMP_INFO *info)
if ( debug_level >= DEBUG_LEVEL_DATA ) if ( debug_level >= DEBUG_LEVEL_DATA )
trace_block(info,info->rx_buf_list_ex[StartIndex].virt_addr, trace_block(info,info->rx_buf_list_ex[StartIndex].virt_addr,
min_t(int, framesize,SCABUFSIZE),0); min_t(unsigned int, framesize, SCABUFSIZE), 0);
if (framesize) { if (framesize) {
if (framesize > info->max_frame_size) if (framesize > info->max_frame_size)
...@@ -5015,14 +5015,14 @@ static void tx_load_dma_buffer(SLMP_INFO *info, const char *buf, unsigned int co ...@@ -5015,14 +5015,14 @@ static void tx_load_dma_buffer(SLMP_INFO *info, const char *buf, unsigned int co
SCADESC_EX *desc_ex; SCADESC_EX *desc_ex;
if ( debug_level >= DEBUG_LEVEL_DATA ) if ( debug_level >= DEBUG_LEVEL_DATA )
trace_block(info,buf, min_t(int, count,SCABUFSIZE), 1); trace_block(info, buf, min_t(unsigned int, count, SCABUFSIZE), 1);
/* Copy source buffer to one or more DMA buffers, starting with /* Copy source buffer to one or more DMA buffers, starting with
* the first transmit dma buffer. * the first transmit dma buffer.
*/ */
for(i=0;;) for(i=0;;)
{ {
copy_count = min_t(unsigned short,count,SCABUFSIZE); copy_count = min_t(unsigned int, count, SCABUFSIZE);
desc = &info->tx_buf_list[i]; desc = &info->tx_buf_list[i];
desc_ex = &info->tx_buf_list_ex[i]; desc_ex = &info->tx_buf_list_ex[i];
......
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