This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit be8499bf7a32f061ebd521d4b4a0da76fd16cc0f Author: Megha Rajput <[email protected]> AuthorDate: Wed Nov 11 19:49:16 2026 +0000 drivers/analog: Fix ADC open count on setup failure. Update the ADC open count only when setup succeeds. A failed first open must not retain a phantom reference. Otherwise, a subsequent open skips initialization and the device's reference count becomes incorrect. Tested: - Simulator build with make -j4. - cmocka_driver_adc_open: 1 test passed. Assisted-by: ChatGPT:GPT-6 Signed-off-by: Megha Rajput <[email protected]> --- drivers/analog/adc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/analog/adc.c b/drivers/analog/adc.c index ff84eb2b152..44886ef2602 100644 --- a/drivers/analog/adc.c +++ b/drivers/analog/adc.c @@ -158,9 +158,12 @@ static int adc_open(FAR struct file *filep) } } - /* Save the new open count on success */ + /* Save the new open count only on success */ - dev->ad_ocount = tmp; + if (ret == OK) + { + dev->ad_ocount = tmp; + } } nxmutex_unlock(&dev->ad_lock);
