From patchwork Tue Jan 24 15:06:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Sjur_Br=C3=A6ndeland?= X-Patchwork-Id: 137575 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 069ACB6EF3 for ; Wed, 25 Jan 2012 02:06:51 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753018Ab2AXPGf (ORCPT ); Tue, 24 Jan 2012 10:06:35 -0500 Received: from mail-qy0-f174.google.com ([209.85.216.174]:48082 "EHLO mail-qy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751156Ab2AXPGd (ORCPT ); Tue, 24 Jan 2012 10:06:33 -0500 Received: by qcsg15 with SMTP id g15so97262qcs.19 for ; Tue, 24 Jan 2012 07:06:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=76pyOSxHyqDmVGIzwwwYYzfaaL07d9K77sz4/zVo5OY=; b=VTLIQXjQ3AY4m5gwze/0zd24X45gFiem81w8sZ2wnC0P1dPc5/9fWYNtKfTFfkfM13 iuGVKEiDNkdgMHi004f1Tstcm5dad0tkt3WYwosdzC5yiQrQKRJrWjlLsqsOGrJoy0Th 0F7hKkeVdtexRuiweYw9L7N5lXgTAKb0MxFEI= MIME-Version: 1.0 Received: by 10.224.185.16 with SMTP id cm16mr15391711qab.0.1327417593102; Tue, 24 Jan 2012 07:06:33 -0800 (PST) Received: by 10.229.228.14 with HTTP; Tue, 24 Jan 2012 07:06:32 -0800 (PST) In-Reply-To: <1327416561.32498.10.camel@lappy> References: <1327390229-30170-1-git-send-email-levinsasha928@gmail.com> <1327416561.32498.10.camel@lappy> Date: Tue, 24 Jan 2012 16:06:32 +0100 Message-ID: Subject: Re: [PATCH] net: caif: Don't act on notification for non-caif devices From: =?UTF-8?Q?Sjur_Br=C3=A6ndeland?= To: Sasha Levin Cc: davem@davemloft.net, davej@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi Sasha, >> Nack, we have to handle other device types than just ARPHDR_CAIF after >> introducing CAIF over USB/NCM. > What my patch did was simply move the type check to above the net_generic call, > it didn't add any new checks - which according to what you said, you'll need to do anyway. As I said I, don't think your patch would work. Try to see what happens if dev->type != ARPHDR_CAIF and caifd != NULL. Then the statement: if (caifd == NULL && dev->type != ARPHRD_CAIF) return 0; is very different from: if (dev->type != ARPHRD_CAIF) return 0; ... if (caifd == NULL) return 0; Anyway, another option could be to explicitly check if name space is initialized, similar to what net_generic() does,e.g. something like: Tested-by: Sasha Levin --- Regards, Sjur -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c index 673728a..3197bc2 100644 --- a/net/caif/caif_dev.c +++ b/net/caif/caif_dev.c @@ -371,6 +371,13 @@ static int caif_device_notify(struct notifier_block *me, un struct cflayer *layer, *link_support; int head_room = 0; struct caif_device_entry_list *caifdevs; + int len; + + rcu_read_lock(); + len = rcu_dereference(dev_net(dev)->gen)->len; + rcu_read_unlock(); + if (caif_net_id > len) + return 0; cfg = get_cfcnfg(dev_net(dev)); caifdevs = caif_device_list(dev_net(dev));