You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by vi...@apache.org on 2021/11/19 18:16:19 UTC

[mynewt-core] branch master updated: hw/drivers/adc_nrf52: Assign the device pointer before un-configuring ADC instance. This prevents accessing NULL pointer inside `channel_unconf()` via `init_instance_unconf()`

This is an automated email from the ASF dual-hosted git repository.

vipulrahane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new a9848fa  hw/drivers/adc_nrf52: Assign the device pointer before un-configuring ADC instance. This prevents accessing NULL pointer inside `channel_unconf()` via `init_instance_unconf()`
     new bf147b5  Merge pull request #2717 from vikrant-proxy/adc-nrf52
a9848fa is described below

commit a9848fa1b6c2edaad5cb3354a0766e7c1aae62d2
Author: Vikrant More <vi...@proxy.com>
AuthorDate: Fri Nov 12 10:13:58 2021 -0800

    hw/drivers/adc_nrf52: Assign the device pointer before un-configuring ADC instance. This prevents accessing NULL pointer inside `channel_unconf()` via `init_instance_unconf()`
---
 hw/drivers/adc/adc_nrf52/src/adc_nrf52.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c b/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
index 8f45942..9dce3de 100644
--- a/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
+++ b/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
@@ -163,10 +163,10 @@ nrf52_adc_open(struct os_dev *odev, uint32_t wait, void *arg)
     }
 
     if (++(dev->ad_ref_cnt) == 1) {
+        global_adc_dev = dev;
         init_instance_unconf();
         NVIC_SetPriority(SAADC_IRQn, 0);
         NVIC_EnableIRQ(SAADC_IRQn);
-        global_adc_dev = dev;
 
         if (adc_config) {
             switch (adc_config->resolution) {