Merge branch 'linux-linaro-lsk-v4.4' into linux-linaro-lsk-v4.4-android

This commit is contained in:
Alex Shi
2018-02-01 12:02:38 +08:00
149 changed files with 1875 additions and 484 deletions

View File

@@ -215,9 +215,16 @@ int read_usb_interface(struct usbip_usb_device *udev, int i,
struct usbip_usb_interface *uinf)
{
char busid[SYSFS_BUS_ID_SIZE];
int size;
struct udev_device *sif;
sprintf(busid, "%s:%d.%d", udev->busid, udev->bConfigurationValue, i);
size = snprintf(busid, sizeof(busid), "%s:%d.%d",
udev->busid, udev->bConfigurationValue, i);
if (size < 0 || (unsigned int)size >= sizeof(busid)) {
err("busid length %i >= %lu or < 0", size,
(unsigned long)sizeof(busid));
return -1;
}
sif = udev_device_new_from_subsystem_sysname(udev_context, "usb", busid);
if (!sif) {

View File

@@ -39,13 +39,19 @@ struct udev *udev_context;
static int32_t read_attr_usbip_status(struct usbip_usb_device *udev)
{
char status_attr_path[SYSFS_PATH_MAX];
int size;
int fd;
int length;
char status;
int value = 0;
snprintf(status_attr_path, SYSFS_PATH_MAX, "%s/usbip_status",
udev->path);
size = snprintf(status_attr_path, SYSFS_PATH_MAX, "%s/usbip_status",
udev->path);
if (size < 0 || (unsigned int)size >= sizeof(status_attr_path)) {
err("usbip_status path length %i >= %lu or < 0", size,
(unsigned long)sizeof(status_attr_path));
return -1;
}
fd = open(status_attr_path, O_RDONLY);
if (fd < 0) {
@@ -225,6 +231,7 @@ int usbip_host_export_device(struct usbip_exported_device *edev, int sockfd)
{
char attr_name[] = "usbip_sockfd";
char sockfd_attr_path[SYSFS_PATH_MAX];
int size;
char sockfd_buff[30];
int ret;
@@ -244,10 +251,20 @@ int usbip_host_export_device(struct usbip_exported_device *edev, int sockfd)
}
/* only the first interface is true */
snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s",
edev->udev.path, attr_name);
size = snprintf(sockfd_attr_path, sizeof(sockfd_attr_path), "%s/%s",
edev->udev.path, attr_name);
if (size < 0 || (unsigned int)size >= sizeof(sockfd_attr_path)) {
err("exported device path length %i >= %lu or < 0", size,
(unsigned long)sizeof(sockfd_attr_path));
return -1;
}
snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd);
size = snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd);
if (size < 0 || (unsigned int)size >= sizeof(sockfd_buff)) {
err("socket length %i >= %lu or < 0", size,
(unsigned long)sizeof(sockfd_buff));
return -1;
}
ret = write_sysfs_attribute(sockfd_attr_path, sockfd_buff,
strlen(sockfd_buff));

View File

@@ -55,12 +55,12 @@ static int parse_status(const char *value)
while (*c != '\0') {
int port, status, speed, devid;
unsigned long socket;
int sockfd;
char lbusid[SYSFS_BUS_ID_SIZE];
ret = sscanf(c, "%d %d %d %x %lx %31s\n",
ret = sscanf(c, "%d %d %d %x %u %31s\n",
&port, &status, &speed,
&devid, &socket, lbusid);
&devid, &sockfd, lbusid);
if (ret < 5) {
dbg("sscanf failed: %d", ret);
@@ -69,7 +69,7 @@ static int parse_status(const char *value)
dbg("port %d status %d speed %d devid %x",
port, status, speed, devid);
dbg("socket %lx lbusid %s", socket, lbusid);
dbg("sockfd %u lbusid %s", sockfd, lbusid);
/* if a device is connected, look at it */

View File

@@ -176,6 +176,8 @@ int main(int argc, char *argv[])
break;
case '?':
printf("usbip: invalid option\n");
/* Terminate after printing error */
/* FALLTHRU */
default:
usbip_usage();
goto out;