No more NULL dereference and kernel panic on current kernels

Found patch on the web:
  http://users.telenet.be/x86_64/Patches/rtl8192eu-k3.13.patch

Before patch, kernel panic due to a NULL dereference in
rtw_ndev_notifier_register; this patch solves that problem by not using
these methods on kernel versions after a certain number, so it leads me
to believe that this patch is meant to make the driver compatible with
newer kernel versions.
This commit is contained in:
Magnus Bergmark 2015-08-18 21:10:30 +02:00
parent 1387cf623d
commit 416453cadc
No known key found for this signature in database
GPG Key ID: DB2D6BB84D8E0309
5 changed files with 20 additions and 6 deletions

View File

@ -116,8 +116,10 @@ void rtw_unregister_netdevs(struct dvobj_priv *dvobj);
u16 rtw_recv_select_queue(struct sk_buff *skb); u16 rtw_recv_select_queue(struct sk_buff *skb);
#endif //LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,35) #endif //LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,35)
#if (LINUX_VERSION_CODE<KERNEL_VERSION(3, 11, 0))
int rtw_ndev_notifier_register(void); int rtw_ndev_notifier_register(void);
void rtw_ndev_notifier_unregister(void); void rtw_ndev_notifier_unregister(void);
#endif
#include "../os_dep/linux/rtw_proc.h" #include "../os_dep/linux/rtw_proc.h"
#endif //PLATFORM_LINUX #endif //PLATFORM_LINUX

View File

@ -601,7 +601,14 @@ unsigned int rtw_classify8021d(struct sk_buff *skb)
return dscp >> 5; return dscp >> 5;
} }
static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb) static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb
#if (LINUX_VERSION_CODE>=KERNEL_VERSION(3, 13, 0))
,void *accel_priv
#endif
#if (LINUX_VERSION_CODE>=KERNEL_VERSION(3, 14, 0))
,select_queue_fallback_t fallback
#endif
)
{ {
_adapter *padapter = rtw_netdev_priv(dev); _adapter *padapter = rtw_netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@ -643,9 +650,9 @@ u16 rtw_recv_select_queue(struct sk_buff *skb)
return rtw_1d_to_queue[priority]; return rtw_1d_to_queue[priority];
} }
#endif #endif
#if (LINUX_VERSION_CODE<KERNEL_VERSION(3, 11, 0))
static int rtw_ndev_notifier_call(struct notifier_block * nb, unsigned long state, void *ndev) static int rtw_ndev_notifier_call(struct notifier_block * nb, unsigned long state, void *ndev)
{ {
struct net_device *dev = ndev; struct net_device *dev = ndev;
@ -681,7 +688,7 @@ void rtw_ndev_notifier_unregister(void)
{ {
unregister_netdevice_notifier(&rtw_ndev_notifier); unregister_netdevice_notifier(&rtw_ndev_notifier);
} }
#endif
int rtw_ndev_init(struct net_device *dev) int rtw_ndev_init(struct net_device *dev)
{ {

View File

@ -763,7 +763,7 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
{ {
#ifdef CONFIG_LPS #ifdef CONFIG_LPS
u8 dtim; u8 dtim;
u8 *ptr = priv_cmd.buf; u8 *ptr = (u8 *) &priv_cmd.buf;
ptr += 9;//string command length of "SET_DTIM"; ptr += 9;//string command length of "SET_DTIM";

View File

@ -319,7 +319,7 @@ int proc_get_rx_info(struct seq_file *m, void *v)
} }
int proc_reset_rx_info(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) ssize_t proc_reset_rx_info(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
{ {
struct net_device *dev = data; struct net_device *dev = data;
_adapter *padapter = (_adapter *)rtw_netdev_priv(dev); _adapter *padapter = (_adapter *)rtw_netdev_priv(dev);

View File

@ -1798,15 +1798,18 @@ static int __init rtw_drv_entry(void)
usb_drv.drv_registered = _TRUE; usb_drv.drv_registered = _TRUE;
rtw_suspend_lock_init(); rtw_suspend_lock_init();
rtw_drv_proc_init(); rtw_drv_proc_init();
#if (LINUX_VERSION_CODE<KERNEL_VERSION(3, 11, 0))
rtw_ndev_notifier_register(); rtw_ndev_notifier_register();
#endif
ret = usb_register(&usb_drv.usbdrv); ret = usb_register(&usb_drv.usbdrv);
if (ret != 0) { if (ret != 0) {
usb_drv.drv_registered = _FALSE; usb_drv.drv_registered = _FALSE;
rtw_suspend_lock_uninit(); rtw_suspend_lock_uninit();
rtw_drv_proc_deinit(); rtw_drv_proc_deinit();
#if (LINUX_VERSION_CODE<KERNEL_VERSION(3, 11, 0))
rtw_ndev_notifier_unregister(); rtw_ndev_notifier_unregister();
#endif
goto exit; goto exit;
} }
@ -1827,7 +1830,9 @@ static void __exit rtw_drv_halt(void)
rtw_suspend_lock_uninit(); rtw_suspend_lock_uninit();
rtw_drv_proc_deinit(); rtw_drv_proc_deinit();
#if (LINUX_VERSION_CODE<KERNEL_VERSION(3, 11, 0))
rtw_ndev_notifier_unregister(); rtw_ndev_notifier_unregister();
#endif
DBG_871X_LEVEL(_drv_always_, "module exit success\n"); DBG_871X_LEVEL(_drv_always_, "module exit success\n");