nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

A few bugfixes

Open kk-thrane opened this issue 1 year ago • 5 comments

Summary

Please let me know if you need the commits in separate pull requests (I'm new at this).

udp_bind: there was an unmatch net_unlock()

tcp: fix non-compliant return value on error

stm32*: fix macro addresses (that doesn't seem to have been used)

Impact

Testing

It works for me.

kk-thrane avatar May 28 '24 20:05 kk-thrane

@wangchen61698 please take a look!

acassis avatar May 28 '24 22:05 acassis

@kk-thrane about you comment "net_unlock() called without a previous call to net_lock()." looking the code it doesn't appear to be the case, net_lock() and net_unlock() seems to be called correctly inside the else block.

Also I think your modification will keep the net blocked for more time.

acassis avatar May 28 '24 22:05 acassis

@acassis as far as I can tell, the calls to net_unlock() in lines 845 and 893 are not preceded by a call to net_lock().

I just mirrored the logic from tcp_ipv4_bind(). Maybe someone with knowledge about the network stack can chip in a better solution?

kk-thrane avatar May 29 '24 15:05 kk-thrane

@acassis as far as I can tell, the calls to net_unlock() in lines 845 and 893 are not preceded by a call to net_lock().

I just mirrored the logic from tcp_ipv4_bind(). Maybe someone with knowledge about the network stack can chip in a better solution?

@wengzhe could you take a look?

xiaoxiang781216 avatar May 29 '24 15:05 xiaoxiang781216

@acassis as far as I can tell, the calls to net_unlock() in lines 845 and 893 are not preceded by a call to net_lock(). I just mirrored the logic from tcp_ipv4_bind(). Maybe someone with knowledge about the network stack can chip in a better solution?

@wengzhe could you take a look?

Yes, I found the PR https://github.com/apache/nuttx/pull/10038/files#diff-e791b12e7112fb69dc700af71b6d8ed95f02b9cc717a3b460e2425d734e60593R846 has added unpaired net_unlock, maybe @wangchen61698 was copying from what he'd written in tcp_ipv*_bind, which has locked at the beginning of the function.

Then back to the current PR, extending the scope of the lock may not harm performance that much:

  • The for loop of net devices is the code we want to protect
  • Other codes are already locked (notice that udp_select_port takes the lock inside.)

So this change is acceptable to me.

wengzhe avatar May 29 '24 15:05 wengzhe

Please advice if i need to do something to get these patches approved

kk-thrane avatar Jun 22 '24 21:06 kk-thrane

Please advice if i need to do something to get these patches approved

I think it is fine. wengzhe already confirmed the unbalanced lock/unlock. I'll merge it now, sorry for missing that!

acassis avatar Jun 22 '24 22:06 acassis