@@ -214,7 +214,6 @@ static int __set_selection_kernel(struct tiocl_selection *v, struct tty_struct *
214
214
if (ps > pe ) /* make sel_start <= sel_end */
215
215
swap (ps , pe );
216
216
217
- mutex_lock (& sel_lock );
218
217
if (sel_cons != vc_cons [fg_console ].d ) {
219
218
clear_selection ();
220
219
sel_cons = vc_cons [fg_console ].d ;
@@ -260,10 +259,9 @@ static int __set_selection_kernel(struct tiocl_selection *v, struct tty_struct *
260
259
break ;
261
260
case TIOCL_SELPOINTER :
262
261
highlight_pointer (pe );
263
- goto unlock ;
262
+ return 0 ;
264
263
default :
265
- ret = - EINVAL ;
266
- goto unlock ;
264
+ return - EINVAL ;
267
265
}
268
266
269
267
/* remove the pointer */
@@ -285,7 +283,7 @@ static int __set_selection_kernel(struct tiocl_selection *v, struct tty_struct *
285
283
else if (new_sel_start == sel_start )
286
284
{
287
285
if (new_sel_end == sel_end ) /* no action required */
288
- goto unlock ;
286
+ return 0 ;
289
287
else if (new_sel_end > sel_end ) /* extend to right */
290
288
highlight (sel_end + 2 , new_sel_end );
291
289
else /* contract from right */
@@ -313,8 +311,7 @@ static int __set_selection_kernel(struct tiocl_selection *v, struct tty_struct *
313
311
if (!bp ) {
314
312
printk (KERN_WARNING "selection: kmalloc() failed\n" );
315
313
clear_selection ();
316
- ret = - ENOMEM ;
317
- goto unlock ;
314
+ return - ENOMEM ;
318
315
}
319
316
kfree (sel_buffer );
320
317
sel_buffer = bp ;
@@ -339,18 +336,19 @@ static int __set_selection_kernel(struct tiocl_selection *v, struct tty_struct *
339
336
}
340
337
}
341
338
sel_buffer_lth = bp - sel_buffer ;
342
- unlock :
343
- mutex_unlock (& sel_lock );
339
+
344
340
return ret ;
345
341
}
346
342
347
343
int set_selection_kernel (struct tiocl_selection * v , struct tty_struct * tty )
348
344
{
349
345
int ret ;
350
346
347
+ mutex_lock (& sel_lock );
351
348
console_lock ();
352
349
ret = __set_selection_kernel (v , tty );
353
350
console_unlock ();
351
+ mutex_unlock (& sel_lock );
354
352
355
353
return ret ;
356
354
}
0 commit comments