diff options
author | Paul Fulghum <paulkf@microgate.com> | 2012-12-03 12:13:24 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-16 00:52:23 -0500 |
commit | a6b68a69fa89daeddc6ca6bb90b6f19a86ed7a9f (patch) | |
tree | 0570429793adb5fba1a3a1f24ee5d669d92c8daa | |
parent | 55c7c0fdc5aae43ca7eda3adb22ab782634fcb24 (diff) |
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>
-rw-r--r-- | drivers/char/pcmcia/synclink_cs.c | 12 | ||||
-rw-r--r-- | drivers/tty/synclink.c | 13 | ||||
-rw-r--r-- | drivers/tty/synclink_gt.c | 18 | ||||
-rw-r--r-- | drivers/tty/synclinkmp.c | 12 |
4 files changed, 47 insertions, 8 deletions
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index b66eaa04f8cb..b2f35d786025 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -210,7 +210,7 @@ typedef struct _mgslpc_info { | |||
210 | char testing_irq; | 210 | char testing_irq; |
211 | unsigned int init_error; /* startup error (DIAGS) */ | 211 | unsigned int init_error; /* startup error (DIAGS) */ |
212 | 212 | ||
213 | char flag_buf[MAX_ASYNC_BUFFER_SIZE]; | 213 | char *flag_buf; |
214 | bool drop_rts_on_tx_done; | 214 | bool drop_rts_on_tx_done; |
215 | 215 | ||
216 | struct _input_signal_events input_signal_events; | 216 | struct _input_signal_events input_signal_events; |
@@ -2674,6 +2674,14 @@ static int rx_alloc_buffers(MGSLPC_INFO *info) | |||
2674 | if (info->rx_buf == NULL) | 2674 | if (info->rx_buf == NULL) |
2675 | return -ENOMEM; | 2675 | return -ENOMEM; |
2676 | 2676 | ||
2677 | /* unused flag buffer to satisfy receive_buf calling interface */ | ||
2678 | info->flag_buf = kzalloc(info->max_frame_size, GFP_KERNEL); | ||
2679 | if (!info->flag_buf) { | ||
2680 | kfree(info->rx_buf); | ||
2681 | info->rx_buf = NULL; | ||
2682 | return -ENOMEM; | ||
2683 | } | ||
2684 | |||
2677 | rx_reset_buffers(info); | 2685 | rx_reset_buffers(info); |
2678 | return 0; | 2686 | return 0; |
2679 | } | 2687 | } |
@@ -2682,6 +2690,8 @@ static void rx_free_buffers(MGSLPC_INFO *info) | |||
2682 | { | 2690 | { |
2683 | kfree(info->rx_buf); | 2691 | kfree(info->rx_buf); |
2684 | info->rx_buf = NULL; | 2692 | info->rx_buf = NULL; |
2693 | kfree(info->flag_buf); | ||
2694 | info->flag_buf = NULL; | ||
2685 | } | 2695 | } |
2686 | 2696 | ||
2687 | static int claim_resources(MGSLPC_INFO *info) | 2697 | static int claim_resources(MGSLPC_INFO *info) |
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c index 9e071f6985f6..d42b66195a49 100644 --- a/drivers/tty/synclink.c +++ b/drivers/tty/synclink.c | |||
@@ -291,8 +291,7 @@ struct mgsl_struct { | |||
291 | bool lcr_mem_requested; | 291 | bool lcr_mem_requested; |
292 | 292 | ||
293 | u32 misc_ctrl_value; | 293 | u32 misc_ctrl_value; |
294 | char flag_buf[MAX_ASYNC_BUFFER_SIZE]; | 294 | char *flag_buf; |
295 | char char_buf[MAX_ASYNC_BUFFER_SIZE]; | ||
296 | bool drop_rts_on_tx_done; | 295 | bool drop_rts_on_tx_done; |
297 | 296 | ||
298 | bool loopmode_insert_requested; | 297 | bool loopmode_insert_requested; |
@@ -3898,7 +3897,13 @@ static int mgsl_alloc_intermediate_rxbuffer_memory(struct mgsl_struct *info) | |||
3898 | info->intermediate_rxbuffer = kmalloc(info->max_frame_size, GFP_KERNEL | GFP_DMA); | 3897 | info->intermediate_rxbuffer = kmalloc(info->max_frame_size, GFP_KERNEL | GFP_DMA); |
3899 | if ( info->intermediate_rxbuffer == NULL ) | 3898 | if ( info->intermediate_rxbuffer == NULL ) |
3900 | return -ENOMEM; | 3899 | return -ENOMEM; |
3901 | 3900 | /* unused flag buffer to satisfy receive_buf calling interface */ | |
3901 | info->flag_buf = kzalloc(info->max_frame_size, GFP_KERNEL); | ||
3902 | if (!info->flag_buf) { | ||
3903 | kfree(info->intermediate_rxbuffer); | ||
3904 | info->intermediate_rxbuffer = NULL; | ||
3905 | return -ENOMEM; | ||
3906 | } | ||
3902 | return 0; | 3907 | return 0; |
3903 | 3908 | ||
3904 | } /* end of mgsl_alloc_intermediate_rxbuffer_memory() */ | 3909 | } /* end of mgsl_alloc_intermediate_rxbuffer_memory() */ |
@@ -3917,6 +3922,8 @@ static void mgsl_free_intermediate_rxbuffer_memory(struct mgsl_struct *info) | |||
3917 | { | 3922 | { |
3918 | kfree(info->intermediate_rxbuffer); | 3923 | kfree(info->intermediate_rxbuffer); |
3919 | info->intermediate_rxbuffer = NULL; | 3924 | info->intermediate_rxbuffer = NULL; |
3925 | kfree(info->flag_buf); | ||
3926 | info->flag_buf = NULL; | ||
3920 | 3927 | ||
3921 | } /* end of mgsl_free_intermediate_rxbuffer_memory() */ | 3928 | } /* end of mgsl_free_intermediate_rxbuffer_memory() */ |
3922 | 3929 | ||
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index aba1e59f4a88..62a0db7ead07 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c | |||
@@ -317,8 +317,7 @@ struct slgt_info { | |||
317 | unsigned char *tx_buf; | 317 | unsigned char *tx_buf; |
318 | int tx_count; | 318 | int tx_count; |
319 | 319 | ||
320 | char flag_buf[MAX_ASYNC_BUFFER_SIZE]; | 320 | char *flag_buf; |
321 | char char_buf[MAX_ASYNC_BUFFER_SIZE]; | ||
322 | bool drop_rts_on_tx_done; | 321 | bool drop_rts_on_tx_done; |
323 | struct _input_signal_events input_signal_events; | 322 | struct _input_signal_events input_signal_events; |
324 | 323 | ||
@@ -3355,11 +3354,24 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3355 | return retval; | 3354 | return retval; |
3356 | } | 3355 | } |
3357 | 3356 | ||
3357 | /* | ||
3358 | * allocate buffers used for calling line discipline receive_buf | ||
3359 | * directly in synchronous mode | ||
3360 | * note: add 5 bytes to max frame size to allow appending | ||
3361 | * 32-bit CRC and status byte when configured to do so | ||
3362 | */ | ||
3358 | static int alloc_tmp_rbuf(struct slgt_info *info) | 3363 | static int alloc_tmp_rbuf(struct slgt_info *info) |
3359 | { | 3364 | { |
3360 | info->tmp_rbuf = kmalloc(info->max_frame_size + 5, GFP_KERNEL); | 3365 | info->tmp_rbuf = kmalloc(info->max_frame_size + 5, GFP_KERNEL); |
3361 | if (info->tmp_rbuf == NULL) | 3366 | if (info->tmp_rbuf == NULL) |
3362 | return -ENOMEM; | 3367 | return -ENOMEM; |
3368 | /* unused flag buffer to satisfy receive_buf calling interface */ | ||
3369 | info->flag_buf = kzalloc(info->max_frame_size + 5, GFP_KERNEL); | ||
3370 | if (!info->flag_buf) { | ||
3371 | kfree(info->tmp_rbuf); | ||
3372 | info->tmp_rbuf = NULL; | ||
3373 | return -ENOMEM; | ||
3374 | } | ||
3363 | return 0; | 3375 | return 0; |
3364 | } | 3376 | } |
3365 | 3377 | ||
@@ -3367,6 +3379,8 @@ static void free_tmp_rbuf(struct slgt_info *info) | |||
3367 | { | 3379 | { |
3368 | kfree(info->tmp_rbuf); | 3380 | kfree(info->tmp_rbuf); |
3369 | info->tmp_rbuf = NULL; | 3381 | info->tmp_rbuf = NULL; |
3382 | kfree(info->flag_buf); | ||
3383 | info->flag_buf = NULL; | ||
3370 | } | 3384 | } |
3371 | 3385 | ||
3372 | /* | 3386 | /* |
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c index fd43fb6f7cee..33b7314cc6c7 100644 --- a/drivers/tty/synclinkmp.c +++ b/drivers/tty/synclinkmp.c | |||
@@ -262,8 +262,7 @@ typedef struct _synclinkmp_info { | |||
262 | bool sca_statctrl_requested; | 262 | bool sca_statctrl_requested; |
263 | 263 | ||
264 | u32 misc_ctrl_value; | 264 | u32 misc_ctrl_value; |
265 | char flag_buf[MAX_ASYNC_BUFFER_SIZE]; | 265 | char *flag_buf; |
266 | char char_buf[MAX_ASYNC_BUFFER_SIZE]; | ||
267 | bool drop_rts_on_tx_done; | 266 | bool drop_rts_on_tx_done; |
268 | 267 | ||
269 | struct _input_signal_events input_signal_events; | 268 | struct _input_signal_events input_signal_events; |
@@ -3553,6 +3552,13 @@ static int alloc_tmp_rx_buf(SLMP_INFO *info) | |||
3553 | info->tmp_rx_buf = kmalloc(info->max_frame_size, GFP_KERNEL); | 3552 | info->tmp_rx_buf = kmalloc(info->max_frame_size, GFP_KERNEL); |
3554 | if (info->tmp_rx_buf == NULL) | 3553 | if (info->tmp_rx_buf == NULL) |
3555 | return -ENOMEM; | 3554 | return -ENOMEM; |
3555 | /* unused flag buffer to satisfy receive_buf calling interface */ | ||
3556 | info->flag_buf = kzalloc(info->max_frame_size, GFP_KERNEL); | ||
3557 | if (!info->flag_buf) { | ||
3558 | kfree(info->tmp_rx_buf); | ||
3559 | info->tmp_rx_buf = NULL; | ||
3560 | return -ENOMEM; | ||
3561 | } | ||
3556 | return 0; | 3562 | return 0; |
3557 | } | 3563 | } |
3558 | 3564 | ||
@@ -3560,6 +3566,8 @@ static void free_tmp_rx_buf(SLMP_INFO *info) | |||
3560 | { | 3566 | { |
3561 | kfree(info->tmp_rx_buf); | 3567 | kfree(info->tmp_rx_buf); |
3562 | info->tmp_rx_buf = NULL; | 3568 | info->tmp_rx_buf = NULL; |
3569 | kfree(info->flag_buf); | ||
3570 | info->flag_buf = NULL; | ||
3563 | } | 3571 | } |
3564 | 3572 | ||
3565 | static int claim_resources(SLMP_INFO *info) | 3573 | static int claim_resources(SLMP_INFO *info) |