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

[MIPS] RTLX: Protect rtlx_{read,write} with mutex.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

+6
+6
arch/mips/kernel/rtlx.c
··· 54 54 wait_queue_head_t rt_queue; 55 55 wait_queue_head_t lx_queue; 56 56 atomic_t in_open; 57 + struct mutex mutex; 57 58 } channel_wqs[RTLX_CHANNELS]; 58 59 59 60 static struct irqaction irq; ··· 315 314 316 315 lx = &rtlx->channel[index]; 317 316 317 + mutex_lock(&channel_wqs[index].mutex); 318 318 smp_rmb(); 319 319 lx_write = lx->lx_write; 320 320 ··· 336 334 smp_wmb(); 337 335 lx->lx_read = (lx->lx_read + count) % lx->buffer_size; 338 336 smp_wmb(); 337 + mutex_unlock(&channel_wqs[index].mutex); 339 338 340 339 return count; 341 340 } ··· 352 349 353 350 rt = &rtlx->channel[index]; 354 351 352 + mutex_lock(&channel_wqs[index].mutex); 355 353 smp_rmb(); 356 354 rt_read = rt->rt_read; 357 355 ··· 372 368 smp_wmb(); 373 369 rt->rt_write = (rt->rt_write + count) % rt->buffer_size; 374 370 smp_wmb(); 371 + mutex_unlock(&channel_wqs[index].mutex); 375 372 376 373 return count; 377 374 } ··· 491 486 init_waitqueue_head(&channel_wqs[i].rt_queue); 492 487 init_waitqueue_head(&channel_wqs[i].lx_queue); 493 488 atomic_set(&channel_wqs[i].in_open, 0); 489 + mutex_init(&channel_wqs[i].mutex); 494 490 495 491 dev = device_create(mt_class, NULL, MKDEV(major, i), 496 492 "%s%d", module_name, i);