@@ -172,6 +172,7 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
172
172
{
173
173
struct uart_port * uport = uart_port_check (state );
174
174
unsigned long page ;
175
+ unsigned long flags = 0 ;
175
176
int retval = 0 ;
176
177
177
178
if (uport -> type == PORT_UNKNOWN )
@@ -186,15 +187,18 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
186
187
* Initialise and allocate the transmit and temporary
187
188
* buffer.
188
189
*/
189
- if (!state -> xmit .buf ) {
190
- /* This is protected by the per port mutex */
191
- page = get_zeroed_page (GFP_KERNEL );
192
- if (!page )
193
- return - ENOMEM ;
190
+ page = get_zeroed_page (GFP_KERNEL );
191
+ if (!page )
192
+ return - ENOMEM ;
194
193
194
+ uart_port_lock (state , flags );
195
+ if (!state -> xmit .buf ) {
195
196
state -> xmit .buf = (unsigned char * ) page ;
196
197
uart_circ_clear (& state -> xmit );
198
+ } else {
199
+ free_page (page );
197
200
}
201
+ uart_port_unlock (uport , flags );
198
202
199
203
retval = uport -> ops -> startup (uport );
200
204
if (retval == 0 ) {
@@ -253,6 +257,7 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
253
257
{
254
258
struct uart_port * uport = uart_port_check (state );
255
259
struct tty_port * port = & state -> port ;
260
+ unsigned long flags = 0 ;
256
261
257
262
/*
258
263
* Set the TTY IO error marker
@@ -285,10 +290,12 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
285
290
/*
286
291
* Free the transmit buffer page.
287
292
*/
293
+ uart_port_lock (state , flags );
288
294
if (state -> xmit .buf ) {
289
295
free_page ((unsigned long )state -> xmit .buf );
290
296
state -> xmit .buf = NULL ;
291
297
}
298
+ uart_port_unlock (uport , flags );
292
299
}
293
300
294
301
/**
0 commit comments