Skip to content

Commit

Permalink
Merge tag 'char-misc-4.12-rc2' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…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()
  • Loading branch information
Linus Torvalds committed May 20, 2017
2 parents ec53c02 + 9434cec commit 331da10
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
6 changes: 5 additions & 1 deletion drivers/char/lp.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,11 @@ static int __init lp_setup (char *str)
} else if (!strcmp(str, "auto")) {
parport_nr[0] = LP_PARPORT_AUTO;
} else if (!strcmp(str, "none")) {
parport_nr[parport_ptr++] = LP_PARPORT_NONE;
if (parport_ptr < LP_NO)
parport_nr[parport_ptr++] = LP_PARPORT_NONE;
else
printk(KERN_INFO "lp: too many ports, %s ignored.\n",
str);
} else if (!strcmp(str, "reset")) {
reset = 1;
}
Expand Down
5 changes: 5 additions & 0 deletions drivers/char/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
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))
return -EINVAL;
Expand Down
21 changes: 15 additions & 6 deletions drivers/firmware/google/vpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,13 @@ static int vpd_section_attrib_add(const u8 *key, s32 key_len,
return VPD_OK;

info = kzalloc(sizeof(*info), GFP_KERNEL);
info->key = kzalloc(key_len + 1, GFP_KERNEL);
if (!info->key)
if (!info)
return -ENOMEM;
info->key = kzalloc(key_len + 1, GFP_KERNEL);
if (!info->key) {
ret = -ENOMEM;
goto free_info;
}

memcpy(info->key, key, key_len);

Expand All @@ -135,12 +139,17 @@ static int vpd_section_attrib_add(const u8 *key, s32 key_len,
list_add_tail(&info->list, &sec->attribs);

ret = sysfs_create_bin_file(sec->kobj, &info->bin_attr);
if (ret) {
kfree(info->key);
return ret;
}
if (ret)
goto free_info_key;

return 0;

free_info_key:
kfree(info->key);
free_info:
kfree(info);

return ret;
}

static void vpd_section_attrib_destroy(struct vpd_section *sec)
Expand Down
1 change: 1 addition & 0 deletions drivers/misc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ config ASPEED_LPC_CTRL

config PCI_ENDPOINT_TEST
depends on PCI
select CRC32
tristate "PCI Endpoint Test driver"
---help---
Enable this configuration option to enable the host side test driver
Expand Down
8 changes: 4 additions & 4 deletions drivers/uio/uio.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
map = kzalloc(sizeof(*map), GFP_KERNEL);
if (!map) {
ret = -ENOMEM;
goto err_map_kobj;
goto err_map;
}
kobject_init(&map->kobj, &map_attr_type);
map->mem = mem;
Expand All @@ -289,7 +289,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
goto err_map_kobj;
ret = kobject_uevent(&map->kobj, KOBJ_ADD);
if (ret)
goto err_map;
goto err_map_kobj;
}

for (pi = 0; pi < MAX_UIO_PORT_REGIONS; pi++) {
Expand All @@ -308,7 +308,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
portio = kzalloc(sizeof(*portio), GFP_KERNEL);
if (!portio) {
ret = -ENOMEM;
goto err_portio_kobj;
goto err_portio;
}
kobject_init(&portio->kobj, &portio_attr_type);
portio->port = port;
Expand All @@ -319,7 +319,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
goto err_portio_kobj;
ret = kobject_uevent(&portio->kobj, KOBJ_ADD);
if (ret)
goto err_portio;
goto err_portio_kobj;
}

return 0;
Expand Down

0 comments on commit 331da10

Please sign in to comment.