2021-08-21 08:54:34 +00:00
|
|
|
From e78b75f5be204a0a235da995d01c778dc282bb42 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Hayes Wang <hayeswang@realtek.com>
|
|
|
|
Date: Fri, 19 Feb 2021 17:04:41 +0800
|
|
|
|
Subject: [PATCH] r8152: check if the pointer of the function exists
|
|
|
|
|
|
|
|
commit c79515e47935c747282c6ed2ee5b2ef039756eeb upstream.
|
|
|
|
|
|
|
|
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>
|
|
|
|
---
|
|
|
|
drivers/net/usb/r8152.c | 13 +++++++++++++
|
|
|
|
1 file changed, 13 insertions(+)
|
|
|
|
|
|
|
|
--- a/drivers/net/usb/r8152.c
|
|
|
|
+++ b/drivers/net/usb/r8152.c
|
2022-03-28 11:54:20 +00:00
|
|
|
@@ -5735,6 +5735,9 @@ static int rtl8152_runtime_suspend(struc
|
2021-08-21 08:54:34 +00:00
|
|
|
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();
|
|
|
|
|
2022-03-28 11:54:20 +00:00
|
|
|
@@ -6134,6 +6137,11 @@ rtl_ethtool_get_eee(struct net_device *n
|
2021-08-21 08:54:34 +00:00
|
|
|
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;
|
2022-03-28 11:54:20 +00:00
|
|
|
@@ -6156,6 +6164,11 @@ rtl_ethtool_set_eee(struct net_device *n
|
2021-08-21 08:54:34 +00:00
|
|
|
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;
|