From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AFD2C433F5 for ; Thu, 14 Oct 2021 15:00:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5AD6E611C7 for ; Thu, 14 Oct 2021 15:00:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232832AbhJNPC6 (ORCPT ); Thu, 14 Oct 2021 11:02:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:43924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233126AbhJNPBe (ORCPT ); Thu, 14 Oct 2021 11:01:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D0E59611C7; Thu, 14 Oct 2021 14:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634223534; bh=leZR35aPtty5VOs+ueNfIGXUEnNejvToOkGTOeg7S8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PFEQ/EU9Fivt1cuCFfBl8+bRFSRt0wXq4QIEQ8FWf6fvpy3DRP8WdgcGKH8W4W9tP 3wQuMaVEhCsNcDUPX48lUYooo7ytaTW8iZLUyhGh86JaekJP7cyf5DBGb/dRZYx1Dx ri/nQtpgZthSSi0boGhSvgCkSA2VcEHc0na78WfU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, MichelleJin , Johannes Berg , Sasha Levin Subject: [PATCH 5.4 11/16] mac80211: check return value of rhashtable_init Date: Thu, 14 Oct 2021 16:54:14 +0200 Message-Id: <20211014145207.686022636@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211014145207.314256898@linuxfoundation.org> References: <20211014145207.314256898@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: MichelleJin [ Upstream commit 111461d573741c17eafad029ac93474fa9adcce0 ] When rhashtable_init() fails, it returns -EINVAL. However, since error return value of rhashtable_init is not checked, it can cause use of uninitialized pointers. So, fix unhandled errors of rhashtable_init. Signed-off-by: MichelleJin Link: https://lore.kernel.org/r/20210927033457.1020967-4-shjy180909@gmail.com Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- net/mac80211/mesh_pathtbl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 1708b64d4109..d7ae7415d54d 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c @@ -60,7 +60,10 @@ static struct mesh_table *mesh_table_alloc(void) atomic_set(&newtbl->entries, 0); spin_lock_init(&newtbl->gates_lock); spin_lock_init(&newtbl->walk_lock); - rhashtable_init(&newtbl->rhead, &mesh_rht_params); + if (rhashtable_init(&newtbl->rhead, &mesh_rht_params)) { + kfree(newtbl); + return NULL; + } return newtbl; } -- 2.33.0