Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp121622ybg; Mon, 8 Jun 2020 18:12:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXac31Wbw+jJTZ0TMV9LYf1WHrFrdH8WWlF25R3EUDhTOYhPQ2Gpp/wbd7LJRRreYlKmkA X-Received: by 2002:a50:ee01:: with SMTP id g1mr23755813eds.44.1591665165923; Mon, 08 Jun 2020 18:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591665165; cv=none; d=google.com; s=arc-20160816; b=f97E9hgEIy8wm1vn0mx3P3Y2Ddbvv02SZ++Jv/wWZ1XOcnCbuFOIHF0ahTvhSE/Y6z /hgyGahi5H2yfHgZAY4obtK+js49Z29N4cNHgIdwPOfIojtYLDYm51/AaNyP+esQ8VrK +74+AYJY/OpeYAbREyk2Ye4xdTRnQk2xbWZhTac3CkuQmbYmPuED7ST1pNFAgk7zaFrr 8q+iQbXMoS2DslTLbDgzXj4HTV+YB0iP8nz2r4YsZ+xW5/9X+Ai2pD0Gkvacx3LYEm9c xnDf9GXa9AtjBSOOYBQpvd65mZq/yY7ydXV+/JnxNUno9o4paRAqvLS4XH/OtPF9xckV giOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=h9NfySpMnDfDbR56a8ZHUqh9WxntamnYw4bNdmNAYyA=; b=FLBrjBfqQNrsNBgBibPvazNSODmyESjd2/Io2AccNcDlsJ+xnycPPi53T99LTDMdjT FppmzQrr+uthPsDgU1bsWs9+KLMM6mpZ+tgIwvF/b6fObmO5Tg9ubm5rG/JKEdVZMcJ7 +TABQpUD25g1CoqYCN3kqQu3Qos8BI7V7cFe6ya2zheJIdSEXqTwlWM5e9HQpTnr9O+K bBHDFHH1gb6fYECRQAaJ6jZtCS24n8qssh5u9KuSn1BKiepwXK05ZN5P+9fgoWF2IXMD 0p+RscQIbTNET/PTpz0ZgjSxn/yLEt61i7S9slj5VmMZ6tRTnESDBamq969j1TsCxl17 6dwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="b0M/xXbY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h3si9124712edz.291.2020.06.08.18.12.23; Mon, 08 Jun 2020 18:12:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="b0M/xXbY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730949AbgFIBIs (ORCPT + 99 others); Mon, 8 Jun 2020 21:08:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:50092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727062AbgFHXGn (ORCPT ); Mon, 8 Jun 2020 19:06:43 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2D20520823; Mon, 8 Jun 2020 23:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657602; bh=nJWsv0/g7G/O3ztFvtszYEgZRxSyuQKlNexXrHnG52E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b0M/xXbYUVXB4qrgPjqoxurgt+AU4P5bBB57R6626Qt++W6YkaalJJzPLO1U3xQhv skDr4Y702LOdjOCynyQg9zipsxQeifV6QjjK3Vk0Ks71YFI2RSO3+PF3142V1F0tTT 24sadTIh6cNfkVk7dPseGIZUr2KgZT28OMNg/tNI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mark Starovoytov , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 028/274] net: atlantic: make hw_get_regs optional Date: Mon, 8 Jun 2020 19:02:01 -0400 Message-Id: <20200608230607.3361041-28-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Starovoytov [ Upstream commit d0f23741c202c685447050713907f3be39a985ee ] This patch fixes potential crash in case if hw_get_regs is NULL. Signed-off-by: Mark Starovoytov Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c index a369705a786a..e5391e0b84f8 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c @@ -764,6 +764,9 @@ int aq_nic_get_regs(struct aq_nic_s *self, struct ethtool_regs *regs, void *p) u32 *regs_buff = p; int err = 0; + if (unlikely(!self->aq_hw_ops->hw_get_regs)) + return -EOPNOTSUPP; + regs->version = 1; err = self->aq_hw_ops->hw_get_regs(self->aq_hw, @@ -778,6 +781,9 @@ int aq_nic_get_regs(struct aq_nic_s *self, struct ethtool_regs *regs, void *p) int aq_nic_get_regs_count(struct aq_nic_s *self) { + if (unlikely(!self->aq_hw_ops->hw_get_regs)) + return 0; + return self->aq_nic_cfg.aq_hw_caps->mac_regs_count; } -- 2.25.1