<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Out of bounds memory write in nrfx_gpiote_in_uninit with new pin</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/57032/out-of-bounds-memory-write-in-nrfx_gpiote_in_uninit-with-new-pin</link><description>The following code has an unexpected out-of-bounds array access: 
 
 
 
 Primary cause is this line: 
 
 On an uninitalized pin number, channel_port_get() returns -1, which is converted to 255 via the cast and this causes out of bounds access in channel_free</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 Mar 2021 16:38:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/57032/out-of-bounds-memory-write-in-nrfx_gpiote_in_uninit-with-new-pin" /><item><title>RE: Out of bounds memory write in nrfx_gpiote_in_uninit with new pin</title><link>https://devzone.nordicsemi.com/thread/297283?ContentTypeID=1</link><pubDate>Tue, 02 Mar 2021 16:38:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05a976fb-eb1c-4ed0-af86-5a79bd7a79b6</guid><dc:creator>kobyfr</dc:creator><description>&lt;p&gt;also happens in SDK 17.0.2 and SDK 15.3&lt;/p&gt;
&lt;p&gt;should modify&amp;nbsp;nrfx_gpiote_in_uninit from this&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void nrfx_gpiote_in_uninit(nrfx_gpiote_pin_t pin)
{
    NRFX_ASSERT(nrf_gpio_pin_present_check(pin));
    NRFX_ASSERT(pin_in_use_by_gpiote(pin));
    nrfx_gpiote_in_event_disable(pin);
    if (pin_in_use_by_te(pin))
    {
        nrf_gpiote_te_default((uint32_t)channel_port_get(pin));
    }
    if (pin_configured_check(pin))
    {
        nrf_gpio_cfg_default(pin);
        pin_configured_clear(pin);
    }
    channel_free((uint8_t)channel_port_get(pin));
    pin_in_use_clear(pin);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;to this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void nrfx_gpiote_in_uninit(nrfx_gpiote_pin_t pin)
{
    NRFX_ASSERT(nrf_gpio_pin_present_check(pin));
    NRFX_ASSERT(pin_in_use_by_gpiote(pin));
    nrfx_gpiote_in_event_disable(pin);
    if (pin_in_use_by_te(pin))
    {
        nrf_gpiote_te_default((uint32_t)channel_port_get(pin));
    }
    if (pin_configured_check(pin))
    {
        nrf_gpio_cfg_default(pin);
        pin_configured_clear(pin);
    }
    if ( pin_in_use(pin) )
    {
        channel_free((uint8_t)channel_port_get(pin));
        pin_in_use_clear(pin);
    }
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Out of bounds memory write in nrfx_gpiote_in_uninit with new pin</title><link>https://devzone.nordicsemi.com/thread/231305?ContentTypeID=1</link><pubDate>Tue, 28 Jan 2020 08:03:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8004d7f-3432-4aa2-89d4-28d192b44062</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for reporting. I have created an internal ticket so that this can be fixed in a future SDK (and nrfx) release.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>