Skip to content

Commit eb889ed

Browse files
mhennerichgastmaier
authored andcommitted
iio: adc: ad9081: use guard(mutex) to protect critical sections
Add guard(mutex) to ad9081_status_show() and ad9081_fir_bin_write() to ensure proper locking when accessing converter state. This prevents potential race conditions during debugfs interactions. Signed-off-by: Michael Hennerich <[email protected]> (cherry picked from commit 70b58c6)
1 parent c3e80d6 commit eb889ed

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/iio/adc/ad9081.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3206,6 +3206,8 @@ static int ad9081_status_show(struct seq_file *file, void *offset)
32063206
u16 stat;
32073207
u8 vals[3];
32083208

3209+
guard(mutex)(&conv->lock);
3210+
32093211
for (l = AD9081_LINK_0; !phy->tx_disable && (l < (ad9081_link_is_dual(phy->jrx_link_tx) ?
32103212
AD9081_LINK_ALL : AD9081_LINK_1)); l++) {
32113213

@@ -3260,9 +3262,6 @@ static int ad9081_status_show(struct seq_file *file, void *offset)
32603262
return 0;
32613263
}
32623264

3263-
3264-
3265-
32663265
static void ad9081_work_func(struct work_struct *work)
32673266
{
32683267
u8 status;
@@ -3568,6 +3567,8 @@ ad9081_fir_bin_write(struct file *filp, struct kobject *kobj,
35683567
struct axiadc_converter *conv = iio_device_get_drvdata(indio_dev);
35693568
struct ad9081_phy *phy = conv->phy;
35703569

3570+
guard(mutex)(&conv->lock);
3571+
35713572
return ad9081_parse_fir(phy, buf, count);
35723573
}
35733574

0 commit comments

Comments
 (0)