Commit 331da109 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'char-misc-4.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char/misc driver fixes from Greg KH:
 "Here are five small bugfixes for reported issues with 4.12-rc1 and
  earlier kernels. Nothing huge here, just a lp, mem, vpd, and uio
  driver fix, along with a Kconfig fixup for one of the misc drivers.

  All of these have been in linux-next with no reported issues"

* tag 'char-misc-4.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
  firmware: Google VPD: Fix memory allocation error handling
  drivers: char: mem: Check for address space wraparound with mmap()
  uio: fix incorrect memory leak cleanup
  misc: pci_endpoint_test: select CRC32
  char: lp: fix possible integer overflow in lp_setup()
parents ec53c027 9434cec1
...@@ -859,7 +859,11 @@ static int __init lp_setup (char *str) ...@@ -859,7 +859,11 @@ static int __init lp_setup (char *str)
} else if (!strcmp(str, "auto")) { } else if (!strcmp(str, "auto")) {
parport_nr[0] = LP_PARPORT_AUTO; parport_nr[0] = LP_PARPORT_AUTO;
} else if (!strcmp(str, "none")) { } else if (!strcmp(str, "none")) {
if (parport_ptr < LP_NO)
parport_nr[parport_ptr++] = LP_PARPORT_NONE; parport_nr[parport_ptr++] = LP_PARPORT_NONE;
else
printk(KERN_INFO "lp: too many ports, %s ignored.\n",
str);
} else if (!strcmp(str, "reset")) { } else if (!strcmp(str, "reset")) {
reset = 1; reset = 1;
} }
......
...@@ -340,6 +340,11 @@ static const struct vm_operations_struct mmap_mem_ops = { ...@@ -340,6 +340,11 @@ static const struct vm_operations_struct mmap_mem_ops = {
static int mmap_mem(struct file *file, struct vm_area_struct *vma) static int mmap_mem(struct file *file, struct vm_area_struct *vma)
{ {
size_t size = vma->vm_end - vma->vm_start; size_t size = vma->vm_end - vma->vm_start;
phys_addr_t offset = (phys_addr_t)vma->vm_pgoff << PAGE_SHIFT;
/* It's illegal to wrap around the end of the physical address space. */
if (offset + (phys_addr_t)size < offset)
return -EINVAL;
if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size)) if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
return -EINVAL; return -EINVAL;
......
...@@ -116,9 +116,13 @@ static int vpd_section_attrib_add(const u8 *key, s32 key_len, ...@@ -116,9 +116,13 @@ static int vpd_section_attrib_add(const u8 *key, s32 key_len,
return VPD_OK; return VPD_OK;
info = kzalloc(sizeof(*info), GFP_KERNEL); info = kzalloc(sizeof(*info), GFP_KERNEL);
info->key = kzalloc(key_len + 1, GFP_KERNEL); if (!info)
if (!info->key)
return -ENOMEM; return -ENOMEM;
info->key = kzalloc(key_len + 1, GFP_KERNEL);
if (!info->key) {
ret = -ENOMEM;
goto free_info;
}
memcpy(info->key, key, key_len); memcpy(info->key, key, key_len);
...@@ -135,12 +139,17 @@ static int vpd_section_attrib_add(const u8 *key, s32 key_len, ...@@ -135,12 +139,17 @@ static int vpd_section_attrib_add(const u8 *key, s32 key_len,
list_add_tail(&info->list, &sec->attribs); list_add_tail(&info->list, &sec->attribs);
ret = sysfs_create_bin_file(sec->kobj, &info->bin_attr); ret = sysfs_create_bin_file(sec->kobj, &info->bin_attr);
if (ret) { if (ret)
kfree(info->key); goto free_info_key;
return ret;
}
return 0; return 0;
free_info_key:
kfree(info->key);
free_info:
kfree(info);
return ret;
} }
static void vpd_section_attrib_destroy(struct vpd_section *sec) static void vpd_section_attrib_destroy(struct vpd_section *sec)
......
...@@ -492,6 +492,7 @@ config ASPEED_LPC_CTRL ...@@ -492,6 +492,7 @@ config ASPEED_LPC_CTRL
config PCI_ENDPOINT_TEST config PCI_ENDPOINT_TEST
depends on PCI depends on PCI
select CRC32
tristate "PCI Endpoint Test driver" tristate "PCI Endpoint Test driver"
---help--- ---help---
Enable this configuration option to enable the host side test driver Enable this configuration option to enable the host side test driver
......
...@@ -279,7 +279,7 @@ static int uio_dev_add_attributes(struct uio_device *idev) ...@@ -279,7 +279,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
map = kzalloc(sizeof(*map), GFP_KERNEL); map = kzalloc(sizeof(*map), GFP_KERNEL);
if (!map) { if (!map) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_map_kobj; goto err_map;
} }
kobject_init(&map->kobj, &map_attr_type); kobject_init(&map->kobj, &map_attr_type);
map->mem = mem; map->mem = mem;
...@@ -289,7 +289,7 @@ static int uio_dev_add_attributes(struct uio_device *idev) ...@@ -289,7 +289,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
goto err_map_kobj; goto err_map_kobj;
ret = kobject_uevent(&map->kobj, KOBJ_ADD); ret = kobject_uevent(&map->kobj, KOBJ_ADD);
if (ret) if (ret)
goto err_map; goto err_map_kobj;
} }
for (pi = 0; pi < MAX_UIO_PORT_REGIONS; pi++) { for (pi = 0; pi < MAX_UIO_PORT_REGIONS; pi++) {
...@@ -308,7 +308,7 @@ static int uio_dev_add_attributes(struct uio_device *idev) ...@@ -308,7 +308,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
portio = kzalloc(sizeof(*portio), GFP_KERNEL); portio = kzalloc(sizeof(*portio), GFP_KERNEL);
if (!portio) { if (!portio) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_portio_kobj; goto err_portio;
} }
kobject_init(&portio->kobj, &portio_attr_type); kobject_init(&portio->kobj, &portio_attr_type);
portio->port = port; portio->port = port;
...@@ -319,7 +319,7 @@ static int uio_dev_add_attributes(struct uio_device *idev) ...@@ -319,7 +319,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
goto err_portio_kobj; goto err_portio_kobj;
ret = kobject_uevent(&portio->kobj, KOBJ_ADD); ret = kobject_uevent(&portio->kobj, KOBJ_ADD);
if (ret) if (ret)
goto err_portio; goto err_portio_kobj;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment