Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus

* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus:
virtio: fix format of sysfs driver/vendor files
Char: virtio_console, fix memory leak
virtio: return correct capacity to users
module: Update prototype for ref_module (formerly use_module)

+13 -35
+9 -28
drivers/char/virtio_console.c
··· 1547 1547 nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2; 1548 1548 1549 1549 vqs = kmalloc(nr_queues * sizeof(struct virtqueue *), GFP_KERNEL); 1550 - if (!vqs) { 1551 - err = -ENOMEM; 1552 - goto fail; 1553 - } 1554 1550 io_callbacks = kmalloc(nr_queues * sizeof(vq_callback_t *), GFP_KERNEL); 1555 - if (!io_callbacks) { 1556 - err = -ENOMEM; 1557 - goto free_vqs; 1558 - } 1559 1551 io_names = kmalloc(nr_queues * sizeof(char *), GFP_KERNEL); 1560 - if (!io_names) { 1561 - err = -ENOMEM; 1562 - goto free_callbacks; 1563 - } 1564 1552 portdev->in_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *), 1565 1553 GFP_KERNEL); 1566 - if (!portdev->in_vqs) { 1567 - err = -ENOMEM; 1568 - goto free_names; 1569 - } 1570 1554 portdev->out_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *), 1571 1555 GFP_KERNEL); 1572 - if (!portdev->out_vqs) { 1556 + if (!vqs || !io_callbacks || !io_names || !portdev->in_vqs || 1557 + !portdev->out_vqs) { 1573 1558 err = -ENOMEM; 1574 - goto free_invqs; 1559 + goto free; 1575 1560 } 1576 1561 1577 1562 /* ··· 1590 1605 io_callbacks, 1591 1606 (const char **)io_names); 1592 1607 if (err) 1593 - goto free_outvqs; 1608 + goto free; 1594 1609 1595 1610 j = 0; 1596 1611 portdev->in_vqs[0] = vqs[0]; ··· 1606 1621 portdev->out_vqs[i] = vqs[j + 1]; 1607 1622 } 1608 1623 } 1609 - kfree(io_callbacks); 1610 1624 kfree(io_names); 1625 + kfree(io_callbacks); 1611 1626 kfree(vqs); 1612 1627 1613 1628 return 0; 1614 1629 1615 - free_names: 1616 - kfree(io_names); 1617 - free_callbacks: 1618 - kfree(io_callbacks); 1619 - free_outvqs: 1630 + free: 1620 1631 kfree(portdev->out_vqs); 1621 - free_invqs: 1622 1632 kfree(portdev->in_vqs); 1623 - free_vqs: 1633 + kfree(io_names); 1634 + kfree(io_callbacks); 1624 1635 kfree(vqs); 1625 - fail: 1636 + 1626 1637 return err; 1627 1638 } 1628 1639
+3 -3
drivers/virtio/virtio.c
··· 9 9 struct device_attribute *attr, char *buf) 10 10 { 11 11 struct virtio_device *dev = container_of(_d,struct virtio_device,dev); 12 - return sprintf(buf, "%hu", dev->id.device); 12 + return sprintf(buf, "0x%04x\n", dev->id.device); 13 13 } 14 14 static ssize_t vendor_show(struct device *_d, 15 15 struct device_attribute *attr, char *buf) 16 16 { 17 17 struct virtio_device *dev = container_of(_d,struct virtio_device,dev); 18 - return sprintf(buf, "%hu", dev->id.vendor); 18 + return sprintf(buf, "0x%04x\n", dev->id.vendor); 19 19 } 20 20 static ssize_t status_show(struct device *_d, 21 21 struct device_attribute *attr, char *buf) 22 22 { 23 23 struct virtio_device *dev = container_of(_d,struct virtio_device,dev); 24 - return sprintf(buf, "0x%08x", dev->config->get_status(dev)); 24 + return sprintf(buf, "0x%08x\n", dev->config->get_status(dev)); 25 25 } 26 26 static ssize_t modalias_show(struct device *_d, 27 27 struct device_attribute *attr, char *buf)
-3
drivers/virtio/virtio_ring.c
··· 230 230 pr_debug("Added buffer head %i to %p\n", head, vq); 231 231 END_USE(vq); 232 232 233 - /* If we're indirect, we can fit many (assuming not OOM). */ 234 - if (vq->indirect) 235 - return vq->num_free ? vq->vring.num : 0; 236 233 return vq->num_free; 237 234 } 238 235 EXPORT_SYMBOL_GPL(virtqueue_add_buf_gfp);
+1 -1
include/linux/module.h
··· 517 517 #define symbol_put_addr(p) do { } while(0) 518 518 519 519 #endif /* CONFIG_MODULE_UNLOAD */ 520 - int use_module(struct module *a, struct module *b); 520 + int ref_module(struct module *a, struct module *b); 521 521 522 522 /* This is a #define so the string doesn't get put in every .o file */ 523 523 #define module_name(mod) \