From patchwork Tue Aug 30 19:16:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 112376 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 5DEC2B6F7B for ; Wed, 31 Aug 2011 05:19:14 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756433Ab1H3TSj (ORCPT ); Tue, 30 Aug 2011 15:18:39 -0400 Received: from mail-pz0-f42.google.com ([209.85.210.42]:33794 "EHLO mail-pz0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756262Ab1H3TSg (ORCPT ); Tue, 30 Aug 2011 15:18:36 -0400 Received: by pzk37 with SMTP id 37so10763558pzk.1 for ; Tue, 30 Aug 2011 12:18:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=Gbuh1lR9huzxteS5TFe8JisD9+iaHKQKahpdF+UCDkY=; b=hPDI/qY9exNIjiGlsSncm3X2ZKxjzTIbFL4O15LvIdF4nzgtonmoh98WJqfh/lIwq9 hqwp9m84MaOz7TZUjRrjlAdDOOSWWQ7oeJDZpRiiJvryC4Y7EG6lCSIAHNFmNtz/ufKA LEFraDRKL22GBeCIkY5hE++feCGeGspNrtX3A= Received: by 10.142.231.9 with SMTP id d9mr3346242wfh.53.1314731916085; Tue, 30 Aug 2011 12:18:36 -0700 (PDT) Received: from shale.localdomain ([41.139.221.94]) by mx.google.com with ESMTPS id s8sm6448104wff.5.2011.08.30.12.18.30 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 30 Aug 2011 12:18:34 -0700 (PDT) Date: Tue, 30 Aug 2011 22:16:15 +0300 From: Dan Carpenter To: javier@cozybit.com Cc: Johannes Berg , "John W. Linville" , "David S. Miller" , "open list:MAC80211" , "open list:NETWORKING [GENERAL]" , kernel-janitors@vger.kernel.org Subject: [patch -next] mac80211: handle allocation failures in mesh_pathtbl_init() Message-ID: <20110830191615.GY3705@shale.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The calls to kzalloc() weren't checked here and it upsets the static checkers. Obviously they're not super likely to fail, but we might as well add some error handling. Signed-off-by: Dan Carpenter --- 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/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 1f91bce..96092e8 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c @@ -1075,6 +1075,7 @@ static int mesh_path_node_copy(struct hlist_node *p, struct mesh_table *newtbl) int mesh_pathtbl_init(void) { struct mesh_table *tbl_path, *tbl_mpp; + int ret; tbl_path = mesh_table_alloc(INIT_PATHS_SIZE_ORDER); if (!tbl_path) @@ -1083,19 +1084,27 @@ int mesh_pathtbl_init(void) tbl_path->copy_node = &mesh_path_node_copy; tbl_path->mean_chain_len = MEAN_CHAIN_LEN; tbl_path->known_gates = kzalloc(sizeof(struct hlist_head), GFP_ATOMIC); + if (!tbl_path->known_gates) { + ret = -ENOMEM; + goto free_path; + } INIT_HLIST_HEAD(tbl_path->known_gates); tbl_mpp = mesh_table_alloc(INIT_PATHS_SIZE_ORDER); if (!tbl_mpp) { - mesh_table_free(tbl_path, true); - return -ENOMEM; + ret = -ENOMEM; + goto free_path; } tbl_mpp->free_node = &mesh_path_node_free; tbl_mpp->copy_node = &mesh_path_node_copy; tbl_mpp->mean_chain_len = MEAN_CHAIN_LEN; /* XXX: not needed */ tbl_mpp->known_gates = kzalloc(sizeof(struct hlist_head), GFP_ATOMIC); + if (!tbl_mpp->known_gates) { + ret = -ENOMEM; + goto free_mpp; + } INIT_HLIST_HEAD(tbl_mpp->known_gates); /* Need no locking since this is during init */ @@ -1103,6 +1112,12 @@ int mesh_pathtbl_init(void) RCU_INIT_POINTER(mpp_paths, tbl_mpp); return 0; + +free_mpp: + mesh_table_free(tbl_mpp, true); +free_path: + mesh_table_free(tbl_path, true); + return ret; } void mesh_path_expire(struct ieee80211_sub_if_data *sdata)