Commit e433b656 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull char/misc driver fixes from Greg KH:
 "Here are some char and misc driver fixes for reported issues.

  One parport patch is reverted as it was incorrect, thanks to testing
  by the 0-day bot"

* tag 'char-misc-4.2-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
  parport: Revert "parport: fix memory leak"
  mei: prevent unloading mei hw modules while the device is opened.
  misc: mic: scif bug fix for vmalloc_to_page crash
  parport: fix freeing freed memory
  parport: fix memory leak
  parport: fix error handling
parents 763e326c 4e5a74f1
...@@ -682,7 +682,7 @@ int mei_register(struct mei_device *dev, struct device *parent) ...@@ -682,7 +682,7 @@ int mei_register(struct mei_device *dev, struct device *parent)
/* Fill in the data structures */ /* Fill in the data structures */
devno = MKDEV(MAJOR(mei_devt), dev->minor); devno = MKDEV(MAJOR(mei_devt), dev->minor);
cdev_init(&dev->cdev, &mei_fops); cdev_init(&dev->cdev, &mei_fops);
dev->cdev.owner = mei_fops.owner; dev->cdev.owner = parent->driver->owner;
/* Add the device */ /* Add the device */
ret = cdev_add(&dev->cdev, devno, 1); ret = cdev_add(&dev->cdev, devno, 1);
......
...@@ -357,7 +357,7 @@ static void scif_p2p_freesg(struct scatterlist *sg) ...@@ -357,7 +357,7 @@ static void scif_p2p_freesg(struct scatterlist *sg)
} }
static struct scatterlist * static struct scatterlist *
scif_p2p_setsg(void __iomem *va, int page_size, int page_cnt) scif_p2p_setsg(phys_addr_t pa, int page_size, int page_cnt)
{ {
struct scatterlist *sg; struct scatterlist *sg;
struct page *page; struct page *page;
...@@ -368,16 +368,11 @@ scif_p2p_setsg(void __iomem *va, int page_size, int page_cnt) ...@@ -368,16 +368,11 @@ scif_p2p_setsg(void __iomem *va, int page_size, int page_cnt)
return NULL; return NULL;
sg_init_table(sg, page_cnt); sg_init_table(sg, page_cnt);
for (i = 0; i < page_cnt; i++) { for (i = 0; i < page_cnt; i++) {
page = vmalloc_to_page((void __force *)va); page = pfn_to_page(pa >> PAGE_SHIFT);
if (!page)
goto p2p_sg_err;
sg_set_page(&sg[i], page, page_size, 0); sg_set_page(&sg[i], page, page_size, 0);
va += page_size; pa += page_size;
} }
return sg; return sg;
p2p_sg_err:
kfree(sg);
return NULL;
} }
/* Init p2p mappings required to access peerdev from scifdev */ /* Init p2p mappings required to access peerdev from scifdev */
...@@ -395,14 +390,14 @@ scif_init_p2p_info(struct scif_dev *scifdev, struct scif_dev *peerdev) ...@@ -395,14 +390,14 @@ scif_init_p2p_info(struct scif_dev *scifdev, struct scif_dev *peerdev)
p2p = kzalloc(sizeof(*p2p), GFP_KERNEL); p2p = kzalloc(sizeof(*p2p), GFP_KERNEL);
if (!p2p) if (!p2p)
return NULL; return NULL;
p2p->ppi_sg[SCIF_PPI_MMIO] = scif_p2p_setsg(psdev->mmio->va, p2p->ppi_sg[SCIF_PPI_MMIO] = scif_p2p_setsg(psdev->mmio->pa,
PAGE_SIZE, num_mmio_pages); PAGE_SIZE, num_mmio_pages);
if (!p2p->ppi_sg[SCIF_PPI_MMIO]) if (!p2p->ppi_sg[SCIF_PPI_MMIO])
goto free_p2p; goto free_p2p;
p2p->sg_nentries[SCIF_PPI_MMIO] = num_mmio_pages; p2p->sg_nentries[SCIF_PPI_MMIO] = num_mmio_pages;
sg_page_shift = get_order(min(psdev->aper->len, (u64)(1 << 30))); sg_page_shift = get_order(min(psdev->aper->len, (u64)(1 << 30)));
num_aper_chunks = num_aper_pages >> (sg_page_shift - PAGE_SHIFT); num_aper_chunks = num_aper_pages >> (sg_page_shift - PAGE_SHIFT);
p2p->ppi_sg[SCIF_PPI_APER] = scif_p2p_setsg(psdev->aper->va, p2p->ppi_sg[SCIF_PPI_APER] = scif_p2p_setsg(psdev->aper->pa,
1 << sg_page_shift, 1 << sg_page_shift,
num_aper_chunks); num_aper_chunks);
p2p->sg_nentries[SCIF_PPI_APER] = num_aper_chunks; p2p->sg_nentries[SCIF_PPI_APER] = num_aper_chunks;
......
...@@ -891,8 +891,10 @@ parport_register_dev_model(struct parport *port, const char *name, ...@@ -891,8 +891,10 @@ parport_register_dev_model(struct parport *port, const char *name,
par_dev->dev.release = free_pardevice; par_dev->dev.release = free_pardevice;
par_dev->devmodel = true; par_dev->devmodel = true;
ret = device_register(&par_dev->dev); ret = device_register(&par_dev->dev);
if (ret) if (ret) {
goto err_put_dev; put_device(&par_dev->dev);
goto err_put_port;
}
/* Chain this onto the list */ /* Chain this onto the list */
par_dev->prev = NULL; par_dev->prev = NULL;
...@@ -907,7 +909,8 @@ parport_register_dev_model(struct parport *port, const char *name, ...@@ -907,7 +909,8 @@ parport_register_dev_model(struct parport *port, const char *name,
spin_unlock(&port->physport->pardevice_lock); spin_unlock(&port->physport->pardevice_lock);
pr_debug("%s: cannot grant exclusive access for device %s\n", pr_debug("%s: cannot grant exclusive access for device %s\n",
port->name, name); port->name, name);
goto err_put_dev; device_unregister(&par_dev->dev);
goto err_put_port;
} }
port->flags |= PARPORT_FLAG_EXCL; port->flags |= PARPORT_FLAG_EXCL;
} }
...@@ -938,8 +941,6 @@ parport_register_dev_model(struct parport *port, const char *name, ...@@ -938,8 +941,6 @@ parport_register_dev_model(struct parport *port, const char *name,
return par_dev; return par_dev;
err_put_dev:
put_device(&par_dev->dev);
err_free_devname: err_free_devname:
kfree(devname); kfree(devname);
err_free_par_dev: err_free_par_dev:
......
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