]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: atlantic: make hw_get_regs optional
authorMark Starovoytov <mstarovoitov@marvell.com>
Thu, 30 Apr 2020 08:04:34 +0000 (11:04 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Jun 2020 07:32:19 +0000 (09:32 +0200)
[ Upstream commit d0f23741c202c685447050713907f3be39a985ee ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/aquantia/atlantic/aq_nic.c

index a369705a786a3300cbbb3070dd8a9f38c3fb598e..e5391e0b84f84cf798b2e311030cbaf707f84fe8 100644 (file)
@@ -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 @@ 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;
 }