Skip to content

Commit

Permalink
r8152: check if the pointer of the function exists
Browse files Browse the repository at this point in the history
Return error code if autosuspend_en, eee_get, or eee_set don't exist.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Hayes Wang authored and Jakub Kicinski committed Feb 23, 2021
1 parent 7a0ae61 commit c79515e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/net/usb/r8152.c
Original file line number Diff line number Diff line change
Expand Up @@ -5757,6 +5757,9 @@ static int rtl8152_runtime_suspend(struct r8152 *tp)
struct net_device *netdev = tp->netdev;
int ret = 0;

if (!tp->rtl_ops.autosuspend_en)
return -EBUSY;

set_bit(SELECTIVE_SUSPEND, &tp->flags);
smp_mb__after_atomic();

Expand Down Expand Up @@ -6156,6 +6159,11 @@ rtl_ethtool_get_eee(struct net_device *net, struct ethtool_eee *edata)
struct r8152 *tp = netdev_priv(net);
int ret;

if (!tp->rtl_ops.eee_get) {
ret = -EOPNOTSUPP;
goto out;
}

ret = usb_autopm_get_interface(tp->intf);
if (ret < 0)
goto out;
Expand All @@ -6178,6 +6186,11 @@ rtl_ethtool_set_eee(struct net_device *net, struct ethtool_eee *edata)
struct r8152 *tp = netdev_priv(net);
int ret;

if (!tp->rtl_ops.eee_set) {
ret = -EOPNOTSUPP;
goto out;
}

ret = usb_autopm_get_interface(tp->intf);
if (ret < 0)
goto out;
Expand Down

0 comments on commit c79515e

Please sign in to comment.