Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp11974545rwb; Sat, 26 Nov 2022 02:22:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf6jdghLTv36JuleIRHragrGRjR2Y5bnYLMiDh7iLmWRKbiBdbUNrdamLFau2hxX3tPFQZBB X-Received: by 2002:a17:903:2112:b0:183:9254:cc70 with SMTP id o18-20020a170903211200b001839254cc70mr23498945ple.18.1669458144051; Sat, 26 Nov 2022 02:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669458144; cv=none; d=google.com; s=arc-20160816; b=OUSpK6+kENnsGSB/AJEF69NFQKUkfg3mW64cIbSYC/0duNddBeeCGplapW3KzzaPuO 40dVkTrGahItue8JazjRh3aogEIBiH2TN7XU5x3ez62kxR/BHFZH0T09Wp4sU7n6Rfm7 1TujT9svXyjDe+iwv6Xc38UL/2CsO0mFHPcr7eeDwUH+3YDfeWqWZGFk1HaEedJ60U9u HHPZ5BiRpyYvjoxbyXH3/fKT/YLb3m40cDnKRjJp0bdrum18uAVLw0zKRcAzeAiwLEGY MoRDPdgjcFH8wN8BSF9qrK7ysWTd+2omTbRpDucqTwYSYl5Ivb//f0J/glrON6ZI5p0e yj2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=zA1smGNy1CLm8XG9HK/Vd4vZmWJqVrkZ5vS9eUztkBI=; b=h+TqSSque6SqipSDap5WStIm5eC2h8lfUa9PgcyDAoS8vE/DU+hG0eEt5dDUdGFdPm ufqy0Um+h2+UmfrNTNDhPhoRDi5CrhE8zdJFH1rjlxidZmT77OLA9AJ1ERLCsSSXGpOk gDYIIhxfIjudzBCQaf9icmGQCET4KTOyJBPPtWubWX1/rheslUs1cNRxMYroa2VG/WeV ZKawsFCb0Ojd8eUEy/0v9DZfmVQNKE3QRKJBpxeK+6rHc3DDGNCGCGxqRTs2oyE4Bids 2H1R8coqxoWNx+WycJLuAl8OAu1h2/R0ZWo7H0+iXKWsQjSB1EirKehG6+McFtrWCn1C J//g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pb15-20020a17090b3c0f00b00218a89aac46si5942826pjb.1.2022.11.26.02.22.16; Sat, 26 Nov 2022 02:22:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229611AbiKZKIq (ORCPT + 67 others); Sat, 26 Nov 2022 05:08:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbiKZKIn (ORCPT ); Sat, 26 Nov 2022 05:08:43 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A36022018A; Sat, 26 Nov 2022 02:08:42 -0800 (PST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NK6qn4RxrzmW9H; Sat, 26 Nov 2022 18:08:05 +0800 (CST) Received: from huawei.com (10.175.112.208) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 26 Nov 2022 18:08:40 +0800 From: Yuan Can To: , , , , , , , , CC: Subject: [PATCH 2/2] wifi: nl80211: Add checks for nla_nest_start() in nl80211_send_iface() Date: Sat, 26 Nov 2022 10:06:34 +0000 Message-ID: <20221126100634.106887-3-yuancan@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221126100634.106887-1-yuancan@huawei.com> References: <20221126100634.106887-1-yuancan@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.208] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org As the nla_nest_start() may fail with NULL returned, the return value needs to be checked. Fixes: ce08cd344a00 ("wifi: nl80211: expose link information for interfaces") Signed-off-by: Yuan Can --- net/wireless/nl80211.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 597c52236514..d2321c683398 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -3868,6 +3868,9 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flag struct cfg80211_chan_def chandef = {}; int ret; + if (!link) + goto nla_put_failure; + if (nla_put_u8(msg, NL80211_ATTR_MLO_LINK_ID, link_id)) goto nla_put_failure; if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, -- 2.17.1