Skip to content

Commit a139ffa

Browse files
angelocgregkh
authored andcommitted
iio: adc: mcp3422: fix locking on error path
Reading from the chip should be unlocked on error path else the lock could never being released. Fixes: 07914c8 ("iio: adc: Add driver for Microchip MCP3422/3/4 high resolution ADC") Fixes: 3f1093d ("iio: adc: mcp3422: fix locking scope") Acked-by: Jonathan Cameron <jonathan.cameron@huawei.com> Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com> Link: https://lore.kernel.org/r/20200901093218.1500845-1-angelo.compagnucci@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c96711e commit a139ffa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/iio/adc/mcp3422.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@ static int mcp3422_read_channel(struct mcp3422 *adc,
143143
config &= ~MCP3422_PGA_MASK;
144144
config |= MCP3422_PGA_VALUE(adc->pga[req_channel]);
145145
ret = mcp3422_update_config(adc, config);
146-
if (ret < 0)
146+
if (ret < 0) {
147+
mutex_unlock(&adc->lock);
147148
return ret;
149+
}
148150
msleep(mcp3422_read_times[MCP3422_SAMPLE_RATE(adc->config)]);
149151
}
150152

0 commit comments

Comments
 (0)