# Re: IPv4/IPv6 sysctl unregistration deadlock

- From: Patrick McHardy \<hidden\>
- Date: 2009-03-02 11:07:15 
- List: netdev
- Page: https://ratatoskr.run/netdev/2009/03/10819220
- Thread: https://ratatoskr.run/netdev/2009/02/10818776/t.md

```text
Stephen Hemminger wrote:
> On Fri, 27 Feb 2009 10:26:43 -0800
> Ben Greear [ref] wrote:
>
>> Stephen Hemminger wrote:
>>
>>> Subject: [PATCH] Avoid race between network down and sysfs
>>>
>>>
>>> Signed-off-by: Stephen Hemminger <redacted>
>>>
>>> --- a/net/core/net-sysfs.c	2009-02-26 08:36:18.000000000 -0800
>>> +++ b/net/core/net-sysfs.c	2009-02-26 08:37:51.000000000 -0800
>>> @@ -77,7 +77,9 @@ static ssize_t netdev_store(struct devic
>>>  	if (endp == buf)
>>>  		goto err;
>>>  
>>> -	rtnl_lock();
>>> +	if (!rtnl_trylock())
>>> +		return -ERESTARTSYS;
>>> +
>>>  	if (dev_isalive(net)) {
>>>  		if ((ret = (*set)(net, new)) == 0)
>>>  			ret = len;
>> I can test this to see if it fixes my problem.  Are the above lines the
>> entirety of the patch?
>
> yes

We should be able to avoid the restart looping in most cases,
we only need to do this while unregistration is in progress.

```
