Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp116608rwb; Mon, 28 Nov 2022 17:53:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf56Jv9fw82FRnLPqwZJbfh/fVDqOyKU2B3wFKyAhtSIfdHI3LGCqVce8WTIm6ZcM0oiPARa X-Received: by 2002:a17:902:6505:b0:186:a7ff:e8ae with SMTP id b5-20020a170902650500b00186a7ffe8aemr34637433plk.77.1669686799116; Mon, 28 Nov 2022 17:53:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669686799; cv=none; d=google.com; s=arc-20160816; b=kBE/AWhW512fdIGT3yKqlseXafA91OmSyHeZJapyj8oyx+/LxJl1T68mTYhIuo7Pta W6CqRzEpWhW6oDpEZCgf/XZ0okOb6wT0/2AaOPuTb0sKMeoz+QYG+lyD2hLFcE7sCHcJ 2OWV/uRR4xrG9yLOpKevP34Z8fq38J5NLZAv50Ndm/mKvvXIZQxlmy1TfrKUXfcof1eq Qgb7BFdGyFTaRyEwM1LoV559GnTThalbcK2xxWArCLSuwYYUgU9GtCCqRpmyGY0MzWWE FAxgVoCTYHRM+gJsiCrQq/6Mpee4x/jLYTc8GWTyu+3skz8fIn4U7tAcVjpgsdEDHsi3 D1SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=zA1smGNy1CLm8XG9HK/Vd4vZmWJqVrkZ5vS9eUztkBI=; b=liNvhjos5LmTTAsF4yi3SG35P1C/+Hdd0f5oRrQkDd6Iqn3P298opPiUpCnzl0q6vK dcGCl/pdUNhJQza6U3O0DZ79/9oHt32E0ze/Alqu6Q7Q0xz2xonepNzFgOIS90LwtWxk r7RyIfQIvSxFZGgL6YNosEzcQa7gN9O7seTVjpzcfRaZpCvIym1R3kks5RRyteKtWCyx ftydpuUbmoG91RS5Z8DuxjEPCS2XLYy8jurkl/G6h14PHd/YHhJbwunMdx/NQCLqzIrh 6f9V34PLlR8g1IZRlOYpqadn7MY/Tlj60DMwAL5JbaaXvSBjoUKufbT2Tz/J6sKkqm/D n7Sg== 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 198-20020a6303cf000000b00477c0882415si12582116pgd.58.2022.11.28.17.53.06; Mon, 28 Nov 2022 17:53:19 -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 S235167AbiK2Boc (ORCPT + 67 others); Mon, 28 Nov 2022 20:44:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235140AbiK2BoZ (ORCPT ); Mon, 28 Nov 2022 20:44:25 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C75442F41; Mon, 28 Nov 2022 17:44:24 -0800 (PST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NLlRJ2RH5zJp0H; Tue, 29 Nov 2022 09:41:00 +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; Tue, 29 Nov 2022 09:44:22 +0800 From: Yuan Can To: , , , , , , CC: Subject: [PATCH RESEND] wifi: nl80211: Add checks for nla_nest_start() in nl80211_send_iface() Date: Tue, 29 Nov 2022 01:42:11 +0000 Message-ID: <20221129014211.56558-1-yuancan@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.208] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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