f13626faf0c9882f1fa7866d82235626fe8a3d69
[openwrt/staging/blogic.git] /
1 From e78b75f5be204a0a235da995d01c778dc282bb42 Mon Sep 17 00:00:00 2001
2 From: Hayes Wang <hayeswang@realtek.com>
3 Date: Fri, 19 Feb 2021 17:04:41 +0800
4 Subject: [PATCH] r8152: check if the pointer of the function exists
5
6 commit c79515e47935c747282c6ed2ee5b2ef039756eeb upstream.
7
8 Return error code if autosuspend_en, eee_get, or eee_set don't exist.
9
10 Signed-off-by: Hayes Wang <hayeswang@realtek.com>
11 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
12 ---
13 drivers/net/usb/r8152.c | 13 +++++++++++++
14 1 file changed, 13 insertions(+)
15
16 --- a/drivers/net/usb/r8152.c
17 +++ b/drivers/net/usb/r8152.c
18 @@ -5737,6 +5737,9 @@ static int rtl8152_runtime_suspend(struc
19 struct net_device *netdev = tp->netdev;
20 int ret = 0;
21
22 + if (!tp->rtl_ops.autosuspend_en)
23 + return -EBUSY;
24 +
25 set_bit(SELECTIVE_SUSPEND, &tp->flags);
26 smp_mb__after_atomic();
27
28 @@ -6136,6 +6139,11 @@ rtl_ethtool_get_eee(struct net_device *n
29 struct r8152 *tp = netdev_priv(net);
30 int ret;
31
32 + if (!tp->rtl_ops.eee_get) {
33 + ret = -EOPNOTSUPP;
34 + goto out;
35 + }
36 +
37 ret = usb_autopm_get_interface(tp->intf);
38 if (ret < 0)
39 goto out;
40 @@ -6158,6 +6166,11 @@ rtl_ethtool_set_eee(struct net_device *n
41 struct r8152 *tp = netdev_priv(net);
42 int ret;
43
44 + if (!tp->rtl_ops.eee_set) {
45 + ret = -EOPNOTSUPP;
46 + goto out;
47 + }
48 +
49 ret = usb_autopm_get_interface(tp->intf);
50 if (ret < 0)
51 goto out;