netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Kurt Van Dijck <kurt.van.dijck@eia.be>
Cc: David Miller <davem@davemloft.net>,
	Linux Netdev List <netdev@vger.kernel.org>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	Urs Thuermann <urs@isnogud.escape.de>
Subject: Re: [PATCH net-next-2.6 v2] can: convert protocol handling to RCU
Date: Wed, 06 Apr 2011 16:39:03 +0200	[thread overview]
Message-ID: <4D9C7B07.20903@hartkopp.net> (raw)
In-Reply-To: <20110406092727.GC342@kurt.e-circ.dyndns.org>

On 06.04.2011 11:27, Kurt Van Dijck wrote:
> On Tue, Apr 05, 2011 at 08:01:16PM +0200, Oliver Hartkopp wrote:

>>  
>> +static struct can_proto *can_try_module_get(int protocol)
>> +{
>> +	struct can_proto *cp;
>> +
>> +	rcu_read_lock();
>> +	cp = rcu_dereference(proto_tab[protocol]);
>> +	if (cp && !try_module_get(cp->prot->owner))
> After the xxx_get, is the 'cp' pointer persistent?

try_module_get() increases the usage counter of the module - therefore it is.
It is protected until module_put(cp->prot->owner) at the end of can_create() .

>>  	/* check for available protocol and correct usage */
>>  
>>  	if (!cp)
>>  		return -EPROTONOSUPPORT;
>>  
>>  	if (cp->type != sock->type) {
> I don't see how this will evaluate to true?
> can_proto_register takes care of it.

This check compares the type of the socket that is to be created with the type
that's defined for this protocol.

E.g. if you would give

s = socket(PF_CAN, SOCK_STREAM, CAN_RAW);

instead of the correct

s = socket(PF_CAN, SOCK_RAW, CAN_RAW);

you will get this error.

>> -		err = -EPROTONOSUPPORT;
>> +		err = -EPROTOTYPE;
>>  		goto errout;
>>  	}
>>  

Regards,
Oliver

  reply	other threads:[~2011-04-06 14:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-05 18:01 [PATCH net-next-2.6 v2] can: convert protocol handling to RCU Oliver Hartkopp
2011-04-06  9:27 ` Kurt Van Dijck
2011-04-06 14:39   ` Oliver Hartkopp [this message]
2011-04-06 15:34     ` Kurt Van Dijck
2011-04-06 19:36       ` David Miller

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=4D9C7B07.20903@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=kurt.van.dijck@eia.be \
    --cc=netdev@vger.kernel.org \
    --cc=urs@isnogud.escape.de \
    /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).