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
6 commit c79515e47935c747282c6ed2ee5b2ef039756eeb upstream.
8 Return error code if autosuspend_en, eee_get, or eee_set don't exist.
10 Signed-off-by: Hayes Wang <hayeswang@realtek.com>
11 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
13 drivers/net/usb/r8152.c | 13 +++++++++++++
14 1 file changed, 13 insertions(+)
16 --- a/drivers/net/usb/r8152.c
17 +++ b/drivers/net/usb/r8152.c
18 @@ -5758,6 +5758,9 @@ static int rtl8152_runtime_suspend(struc
19 struct net_device *netdev = tp->netdev;
22 + if (!tp->rtl_ops.autosuspend_en)
25 set_bit(SELECTIVE_SUSPEND, &tp->flags);
26 smp_mb__after_atomic();
28 @@ -6157,6 +6160,11 @@ rtl_ethtool_get_eee(struct net_device *n
29 struct r8152 *tp = netdev_priv(net);
32 + if (!tp->rtl_ops.eee_get) {
37 ret = usb_autopm_get_interface(tp->intf);
40 @@ -6179,6 +6187,11 @@ rtl_ethtool_set_eee(struct net_device *n
41 struct r8152 *tp = netdev_priv(net);
44 + if (!tp->rtl_ops.eee_set) {
49 ret = usb_autopm_get_interface(tp->intf);