staging: vt6655: preserve address space by not casting
PATCH 1/1 staging: vt6655: preserve address space by not casting
Fix the sparse error: cast removes address space of expression.
---
Is that even correct? I haven't signed-off on it yet. ethtool_ioctl() takes a (void *) as user data, dereferenced and assigend to u32. applies to next-20140611
drivers/staging/vt6655/device_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vt6655/device_main.c +1 -1
@@ -3067,7 +3067,7 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {break ;case SIOCETHTOOL : -return ethtool_ioctl (dev, (void *)rq->ifr_data); +return ethtool_ioctl (dev, &rq->ifr_data);// All other calls are currently unsupported default :
Signature · 1 line
1.7.10.4
Quoted 3 lines · Martin Kepplinger
Fix the sparse error: cast removes address space of expression.
---
Is that even correct?
It's correct but not complete.
vt6655 impliment their own versions of ethtool_ioctl() when they should be using the standard versions.
The vt6655 version of ethtool_ioctl() should be annotated so it's marked that the second parameter is marked as a __user pointer. It doesn't print a Sparse warning because at a certain point Sparse just says:
"warning: too many warnings" and gives up.
Quoted 3 lines
I haven't signed-off on it yet.
ethtool_ioctl()takes a (void *) as user data, dereferenced and assigend to u32. applies to next-20140611
It doesn't dereference the pointer. You are getting mixed up with the vt6656 version of ethtool_ioctl() I think? You're not allowed to dereference __user pointers.
regards,
dan carpenter
PATCH v2 1/1 staging: vt6655: preserve address space in ethtool_ioctl()
Fix the sparse error: cast removes address space of expression and add __user annotation to the driver's ethtool_ioctl().
---
Beyond that, how would you include socket.c's ethtool_ioctl() here?
thanks for looking at these tiny changes.
drivers/staging/vt6655/device_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vt6655/device_main.c +2 -2
@@ -3067,7 +3067,7 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {break ;case SIOCETHTOOL : -return ethtool_ioctl (dev, (void *)rq->ifr_data); +return ethtool_ioctl (dev, &rq->ifr_data);// All other calls are currently unsupported default :
@@ -3103,7 +3103,7 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {return rc; } -static int ethtool_ioctl (struct net_device *dev,void *useraddr) +static int ethtool_ioctl (struct net_device *dev,void __user *useraddr) {u32 ethcmd;
Signature · 1 line
1.7.10.4
PATCH v3 1/1 staging: vt6655: preserve address space in ethtool_ioctl()
Fix the sparse error: cast removes address space of expression and add __user annotation to the driver's ethtool_ioctl().
---
I think I forgot to change the declaration on top.
drivers/staging/vt6655/device_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/vt6655/device_main.c +3 -3
@@ -302,7 +302,7 @@ static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev);//2008-0714<Add>by Mike Liu static bool device_release_WPADEV (PSDevice pDevice); -static int ethtool_ioctl (struct net_device *dev,void *useraddr); +static int ethtool_ioctl (struct net_device *dev,void __user *useraddr);static int device_rx_srv (PSDevice pDevice,unsigned int uIdx);static int device_tx_srv (PSDevice pDevice,unsigned int uIdx);static bool device_alloc_rx_buf (PSDevice pDevice,PSRxDesc pDesc);
@@ -3067,7 +3067,7 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {break ;case SIOCETHTOOL : -return ethtool_ioctl (dev, (void *)rq->ifr_data); +return ethtool_ioctl (dev, &rq->ifr_data);// All other calls are currently unsupported default :
@@ -3103,7 +3103,7 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {return rc; } -static int ethtool_ioctl (struct net_device *dev,void *useraddr) +static int ethtool_ioctl (struct net_device *dev,void __user *useraddr) {u32 ethcmd;
Signature · 1 line
1.7.10.4
Greg KH
maintainerRe: [PATCH v3] staging: vt6655: preserve address space in ethtool_ioctl()
Quoted 6 lines · Martin Kepplinger
Fix the sparse error: cast removes address space of expression and add
__userannotation to the driver'sethtool_ioctl().Signed-off-by Martin Kepplinger <[email protected]>---
I think I forgot to change the declaration on top.
Someone else did this change just before you did, sorry :(