netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarek Poplawski <jarkao2@gmail.com>
To: Patrick McHardy <kaber@trash.net>
Cc: David Miller <davem@davemloft.net>,
	Jamal Hadi Salim <hadi@cyberus.ca>,
	netdev@vger.kernel.org
Subject: Re: [PATCH][NET_SCHED] cls_u32: refcounting fix for u32_delete()
Date: Fri, 11 Apr 2008 13:23:04 +0000	[thread overview]
Message-ID: <20080411132304.GB2701@ff.dom.local> (raw)
In-Reply-To: <47FF5FBF.6030802@trash.net>

On Fri, Apr 11, 2008 at 02:55:27PM +0200, Patrick McHardy wrote:
> Jarek Poplawski wrote:
>> [NET_SCHED] cls_u32: refcounting fix for u32_delete()
>>
>> @@ -441,8 +443,10 @@ static int u32_delete(struct tcf_proto *tp, unsigned long arg)
>>  	if (tp->root == ht)
>>  		return -EINVAL;
>>  -	if (--ht->refcnt == 0)
>> +	if (ht->refcnt == 1) {
>> +		ht->refcnt--;
>>  		u32_destroy_hnode(tp, ht);
>> +	}
>>  
>
> Shouldn't the refcount be decremented unconditionally?
> Otherwise I'd suggest to reject the removal if refcnt > 1,
> but silently doing nothing doesn't seem right.

If someone tries deleting and the refcnt is e.g. 3 (2 links)
unconditional deleting could decrease refcnt without deleting
and then unlinking would make it below 0. I think it's OK now:
we can't delete hnode until it's referenced, but I could add
a warning if you like?

Thanks,
Jarek P.

  reply	other threads:[~2008-04-11 13:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-11 12:45 [PATCH][NET_SCHED] cls_u32: refcounting fix for u32_delete() Jarek Poplawski
2008-04-11 12:55 ` Patrick McHardy
2008-04-11 13:23   ` Jarek Poplawski [this message]
2008-04-11 13:22     ` Patrick McHardy
2008-04-11 13:48       ` [PATCH take2][NET_SCHED] " Jarek Poplawski
2008-04-11 13:55         ` jamal
2008-04-13  1:37           ` David Miller
2008-04-11 14:00         ` Patrick McHardy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080411132304.GB2701@ff.dom.local \
    --to=jarkao2@gmail.com \
    --cc=davem@davemloft.net \
    --cc=hadi@cyberus.ca \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).