From patchwork Tue Mar 3 17:41:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 230056 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69425C3F2D7 for ; Tue, 3 Mar 2020 17:45:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3BD5422522 for ; Tue, 3 Mar 2020 17:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583257540; bh=9O5ymUWpNt3jhqdPiucuIYgwSShPohd5ByDTUrD1C6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=DOUqSK+v0blP+55oEeKr2tkuaL+e7Xhz9OirH0zQa/KQ/A0+XTxIKY4/y1xqxNe07 t0WHL94Zi++JHJOhQi5/E2Ac3vWwl4PFanW/PVphI1PvG7ej0+mpnCFMZcS80yA5V5 PH00SCnti/MkbkIkjp7MfczuRRd69TitsYUWTeCA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730964AbgCCRpj (ORCPT ); Tue, 3 Mar 2020 12:45:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:51774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730944AbgCCRpi (ORCPT ); Tue, 3 Mar 2020 12:45:38 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 962AC2146E; Tue, 3 Mar 2020 17:45:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583257538; bh=9O5ymUWpNt3jhqdPiucuIYgwSShPohd5ByDTUrD1C6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O/zrZ+ljo8G9ONmjAYJT2F7r8PdcyJvyGKkKb1Vb6bq3JkyVk1gssLOtGI2Nb+BCB 53jqvmaiVIpDgFp37h2x6M+7FKICxmHlSYDvNasi6kbXeG+5Wl3YdAFNKBo/hZsNTj p/d7t9NTxxvPk3C+gkvJ6U0WQnrsJht4XTXniX7A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergey Matyukevich , Johannes Berg , Sasha Levin Subject: [PATCH 5.5 032/176] cfg80211: check wiphy driver existence for drvinfo report Date: Tue, 3 Mar 2020 18:41:36 +0100 Message-Id: <20200303174308.233945992@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200303174304.593872177@linuxfoundation.org> References: <20200303174304.593872177@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sergey Matyukevich [ Upstream commit bfb7bac3a8f47100ebe7961bd14e924c96e21ca7 ] When preparing ethtool drvinfo, check if wiphy driver is defined before dereferencing it. Driver may not exist, e.g. if wiphy is attached to a virtual platform device. Signed-off-by: Sergey Matyukevich Link: https://lore.kernel.org/r/20200203105644.28875-1-sergey.matyukevich.os@quantenna.com Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- net/wireless/ethtool.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/wireless/ethtool.c b/net/wireless/ethtool.c index a9c0f368db5d2..24e18405cdb48 100644 --- a/net/wireless/ethtool.c +++ b/net/wireless/ethtool.c @@ -7,9 +7,13 @@ void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct wireless_dev *wdev = dev->ieee80211_ptr; + struct device *pdev = wiphy_dev(wdev->wiphy); - strlcpy(info->driver, wiphy_dev(wdev->wiphy)->driver->name, - sizeof(info->driver)); + if (pdev->driver) + strlcpy(info->driver, pdev->driver->name, + sizeof(info->driver)); + else + strlcpy(info->driver, "N/A", sizeof(info->driver)); strlcpy(info->version, init_utsname()->release, sizeof(info->version));