Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

synclink fix ldisc buffer argument

Fix call to line discipline receive_buf by synclink drivers.
Dummy flag buffer argument is ignored by N_HDLC line discipline but might
be of insufficient size if accessed by a different line discipline
selected by mistake. flag buffer allocation now matches max size of data
buffer. Unused char_buf buffers are removed.

Signed-off-by: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Paul Fulghum and committed by
Greg Kroah-Hartman
a6b68a69 55c7c0fd

+47 -8
+10 -3
drivers/tty/synclink.c
··· 291 291 bool lcr_mem_requested; 292 292 293 293 u32 misc_ctrl_value; 294 - char flag_buf[MAX_ASYNC_BUFFER_SIZE]; 295 - char char_buf[MAX_ASYNC_BUFFER_SIZE]; 294 + char *flag_buf; 296 295 bool drop_rts_on_tx_done; 297 296 298 297 bool loopmode_insert_requested; ··· 3897 3898 info->intermediate_rxbuffer = kmalloc(info->max_frame_size, GFP_KERNEL | GFP_DMA); 3898 3899 if ( info->intermediate_rxbuffer == NULL ) 3899 3900 return -ENOMEM; 3900 - 3901 + /* unused flag buffer to satisfy receive_buf calling interface */ 3902 + info->flag_buf = kzalloc(info->max_frame_size, GFP_KERNEL); 3903 + if (!info->flag_buf) { 3904 + kfree(info->intermediate_rxbuffer); 3905 + info->intermediate_rxbuffer = NULL; 3906 + return -ENOMEM; 3907 + } 3901 3908 return 0; 3902 3909 3903 3910 } /* end of mgsl_alloc_intermediate_rxbuffer_memory() */ ··· 3922 3917 { 3923 3918 kfree(info->intermediate_rxbuffer); 3924 3919 info->intermediate_rxbuffer = NULL; 3920 + kfree(info->flag_buf); 3921 + info->flag_buf = NULL; 3925 3922 3926 3923 } /* end of mgsl_free_intermediate_rxbuffer_memory() */ 3927 3924
+10 -2
drivers/tty/synclinkmp.c
··· 262 262 bool sca_statctrl_requested; 263 263 264 264 u32 misc_ctrl_value; 265 - char flag_buf[MAX_ASYNC_BUFFER_SIZE]; 266 - char char_buf[MAX_ASYNC_BUFFER_SIZE]; 265 + char *flag_buf; 267 266 bool drop_rts_on_tx_done; 268 267 269 268 struct _input_signal_events input_signal_events; ··· 3552 3553 info->tmp_rx_buf = kmalloc(info->max_frame_size, GFP_KERNEL); 3553 3554 if (info->tmp_rx_buf == NULL) 3554 3555 return -ENOMEM; 3556 + /* unused flag buffer to satisfy receive_buf calling interface */ 3557 + info->flag_buf = kzalloc(info->max_frame_size, GFP_KERNEL); 3558 + if (!info->flag_buf) { 3559 + kfree(info->tmp_rx_buf); 3560 + info->tmp_rx_buf = NULL; 3561 + return -ENOMEM; 3562 + } 3555 3563 return 0; 3556 3564 } 3557 3565 ··· 3566 3560 { 3567 3561 kfree(info->tmp_rx_buf); 3568 3562 info->tmp_rx_buf = NULL; 3563 + kfree(info->flag_buf); 3564 + info->flag_buf = NULL; 3569 3565 } 3570 3566 3571 3567 static int claim_resources(SLMP_INFO *info)