Merge "usb: gadget: u_ether: Add NULL check in helper APIs"
This commit is contained in:
commit
234a1f3c32
1 changed files with 21 additions and 0 deletions
|
@ -1073,6 +1073,9 @@ int gether_set_dev_addr(struct net_device *net, const char *dev_addr)
|
|||
struct eth_dev *dev;
|
||||
u8 new_addr[ETH_ALEN];
|
||||
|
||||
if (!net)
|
||||
return -ENODEV;
|
||||
|
||||
dev = netdev_priv(net);
|
||||
if (get_ether_addr(dev_addr, new_addr))
|
||||
return -EINVAL;
|
||||
|
@ -1085,6 +1088,9 @@ int gether_get_dev_addr(struct net_device *net, char *dev_addr, int len)
|
|||
{
|
||||
struct eth_dev *dev;
|
||||
|
||||
if (!net)
|
||||
return -ENODEV;
|
||||
|
||||
dev = netdev_priv(net);
|
||||
return get_ether_addr_str(dev->dev_mac, dev_addr, len);
|
||||
}
|
||||
|
@ -1095,6 +1101,9 @@ int gether_set_host_addr(struct net_device *net, const char *host_addr)
|
|||
struct eth_dev *dev;
|
||||
u8 new_addr[ETH_ALEN];
|
||||
|
||||
if (!net)
|
||||
return -ENODEV;
|
||||
|
||||
dev = netdev_priv(net);
|
||||
if (get_ether_addr(host_addr, new_addr))
|
||||
return -EINVAL;
|
||||
|
@ -1107,6 +1116,9 @@ int gether_get_host_addr(struct net_device *net, char *host_addr, int len)
|
|||
{
|
||||
struct eth_dev *dev;
|
||||
|
||||
if (!net)
|
||||
return -ENODEV;
|
||||
|
||||
dev = netdev_priv(net);
|
||||
return get_ether_addr_str(dev->host_mac, host_addr, len);
|
||||
}
|
||||
|
@ -1139,6 +1151,9 @@ void gether_set_qmult(struct net_device *net, unsigned qmult)
|
|||
{
|
||||
struct eth_dev *dev;
|
||||
|
||||
if (!net)
|
||||
return;
|
||||
|
||||
dev = netdev_priv(net);
|
||||
dev->qmult = qmult;
|
||||
}
|
||||
|
@ -1148,6 +1163,9 @@ unsigned gether_get_qmult(struct net_device *net)
|
|||
{
|
||||
struct eth_dev *dev;
|
||||
|
||||
if (!net)
|
||||
return -ENODEV;
|
||||
|
||||
dev = netdev_priv(net);
|
||||
return dev->qmult;
|
||||
}
|
||||
|
@ -1155,6 +1173,9 @@ EXPORT_SYMBOL_GPL(gether_get_qmult);
|
|||
|
||||
int gether_get_ifname(struct net_device *net, char *name, int len)
|
||||
{
|
||||
if (!net)
|
||||
return -ENODEV;
|
||||
|
||||
rtnl_lock();
|
||||
strlcpy(name, netdev_name(net), len);
|
||||
rtnl_unlock();
|
||||
|
|
Loading…
Add table
Reference in a new issue