summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorMark Starovoytov <mstarovoitov@marvell.com>2020-04-30 11:04:34 +0300
committerDavid S. Miller <davem@davemloft.net>2020-05-02 01:37:58 +0300
commitd0f23741c202c685447050713907f3be39a985ee (patch)
treeee4a1352caaec18a37e1a0fe1eaecfd29da0ac4a /drivers/net
parent36e90a5297ea02c67c0f17d8b39eb9ceb93dd6f0 (diff)
downloadlinux-d0f23741c202c685447050713907f3be39a985ee.tar.xz
net: atlantic: make hw_get_regs optional
This patch fixes potential crash in case if hw_get_regs is NULL. Signed-off-by: Mark Starovoytov <mstarovoitov@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/aq_nic.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
index 57102f35e9f3..2dbea5cd7684 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
@@ -778,6 +778,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,
@@ -792,6 +795,9 @@ err_exit:
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;
}