Skip to content

Commit 3a2d3d2

Browse files
alcosargregkh
authored andcommitted
drivers: misc: ti-st: fix potential race if st_kim_start fails
If st_kim_start() fails registered protocols should be removed. This is done by calling st_reg_complete(), which as comment states is called with spin lock held. But in st_register() when st_kim_start fails it is called without holding spin lock, creating possibility of concurrent access to st_gdata data members. Hold spin lock while calling st_reg_complete if st_kim_start() fails. Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@globallogic.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 666b9ad commit 3a2d3d2

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎drivers/misc/ti-st/st_core.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,9 @@ long st_register(struct st_proto_s *new_proto)
562562
if ((st_gdata->protos_registered != ST_EMPTY) &&
563563
(test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
564564
pr_err(" KIM failure complete callback ");
565+
spin_lock_irqsave(&st_gdata->lock, flags);
565566
st_reg_complete(st_gdata, err);
567+
spin_unlock_irqrestore(&st_gdata->lock, flags);
566568
clear_bit(ST_REG_PENDING, &st_gdata->st_state);
567569
}
568570
return -EINVAL;

0 commit comments

Comments
 (0)