Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751825AbdITXFZ (ORCPT ); Wed, 20 Sep 2017 19:05:25 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:41752 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751584AbdITXFY (ORCPT ); Wed, 20 Sep 2017 19:05:24 -0400 Date: Wed, 20 Sep 2017 16:05:19 -0700 (PDT) Message-Id: <20170920.160519.764603868579556859.davem@davemloft.net> To: sam@mendozajonas.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net] net/ncsi: Don't assume last available channel exists From: David Miller In-Reply-To: <20170920041251.14635-1-sam@mendozajonas.com> References: <20170920041251.14635-1-sam@mendozajonas.com> X-Mailer: Mew version 6.7 on Emacs 25.2 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Wed, 20 Sep 2017 16:05:20 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 945 Lines: 27 From: Samuel Mendoza-Jonas Date: Wed, 20 Sep 2017 14:12:51 +1000 > When handling new VLAN tags in NCSI we check the maximum allowed number > of filters on the last active ("hot") channel. However if the 'add' > callback is called before NCSI has configured a channel, this causes a > NULL dereference. > > Check that we actually have a hot channel, and warn if it is missing. > > Signed-off-by: Samuel Mendoza-Jonas Well, a few things. We should not allow this driver method to be invoked in the first place if the device is not in a state where the operation is legal yet. Second of all, if !ndp is true, you should not return 0 to indicate success. But more fundamentally, we should block this method from being callable unless the device is in the proper state and can complete the operation. Seriously, these checks should be completely unnecessary if those issues are handled properly.