OSDN Git Service

net: atlantic: make hw_get_regs optional
authorMark Starovoytov <mstarovoitov@marvell.com>
Thu, 30 Apr 2020 08:04:34 +0000 (11:04 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 May 2020 22:37:58 +0000 (15:37 -0700)
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>
drivers/net/ethernet/aquantia/atlantic/aq_nic.c

index 57102f3..2dbea5c 100644 (file)
@@ -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;
 }