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)
This commit is contained in:
Linus Torvalds 2010-11-25 06:57:11 +09:00
commit c42978f7ec
4 changed files with 13 additions and 35 deletions

View File

@ -1547,31 +1547,16 @@ static int init_vqs(struct ports_device *portdev)
nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2; nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2;
vqs = kmalloc(nr_queues * sizeof(struct virtqueue *), GFP_KERNEL); vqs = kmalloc(nr_queues * sizeof(struct virtqueue *), GFP_KERNEL);
if (!vqs) {
err = -ENOMEM;
goto fail;
}
io_callbacks = kmalloc(nr_queues * sizeof(vq_callback_t *), GFP_KERNEL); io_callbacks = kmalloc(nr_queues * sizeof(vq_callback_t *), GFP_KERNEL);
if (!io_callbacks) {
err = -ENOMEM;
goto free_vqs;
}
io_names = kmalloc(nr_queues * sizeof(char *), GFP_KERNEL); io_names = kmalloc(nr_queues * sizeof(char *), GFP_KERNEL);
if (!io_names) {
err = -ENOMEM;
goto free_callbacks;
}
portdev->in_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *), portdev->in_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),
GFP_KERNEL); GFP_KERNEL);
if (!portdev->in_vqs) {
err = -ENOMEM;
goto free_names;
}
portdev->out_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *), portdev->out_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),
GFP_KERNEL); GFP_KERNEL);
if (!portdev->out_vqs) { if (!vqs || !io_callbacks || !io_names || !portdev->in_vqs ||
!portdev->out_vqs) {
err = -ENOMEM; err = -ENOMEM;
goto free_invqs; goto free;
} }
/* /*
@ -1605,7 +1590,7 @@ static int init_vqs(struct ports_device *portdev)
io_callbacks, io_callbacks,
(const char **)io_names); (const char **)io_names);
if (err) if (err)
goto free_outvqs; goto free;
j = 0; j = 0;
portdev->in_vqs[0] = vqs[0]; portdev->in_vqs[0] = vqs[0];
@ -1621,23 +1606,19 @@ static int init_vqs(struct ports_device *portdev)
portdev->out_vqs[i] = vqs[j + 1]; portdev->out_vqs[i] = vqs[j + 1];
} }
} }
kfree(io_callbacks);
kfree(io_names); kfree(io_names);
kfree(io_callbacks);
kfree(vqs); kfree(vqs);
return 0; return 0;
free_names: free:
kfree(io_names);
free_callbacks:
kfree(io_callbacks);
free_outvqs:
kfree(portdev->out_vqs); kfree(portdev->out_vqs);
free_invqs:
kfree(portdev->in_vqs); kfree(portdev->in_vqs);
free_vqs: kfree(io_names);
kfree(io_callbacks);
kfree(vqs); kfree(vqs);
fail:
return err; return err;
} }

View File

@ -9,19 +9,19 @@ static ssize_t device_show(struct device *_d,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct virtio_device *dev = container_of(_d,struct virtio_device,dev); struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
return sprintf(buf, "%hu", dev->id.device); return sprintf(buf, "0x%04x\n", dev->id.device);
} }
static ssize_t vendor_show(struct device *_d, static ssize_t vendor_show(struct device *_d,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct virtio_device *dev = container_of(_d,struct virtio_device,dev); struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
return sprintf(buf, "%hu", dev->id.vendor); return sprintf(buf, "0x%04x\n", dev->id.vendor);
} }
static ssize_t status_show(struct device *_d, static ssize_t status_show(struct device *_d,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct virtio_device *dev = container_of(_d,struct virtio_device,dev); struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
return sprintf(buf, "0x%08x", dev->config->get_status(dev)); return sprintf(buf, "0x%08x\n", dev->config->get_status(dev));
} }
static ssize_t modalias_show(struct device *_d, static ssize_t modalias_show(struct device *_d,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)

View File

@ -230,9 +230,6 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
pr_debug("Added buffer head %i to %p\n", head, vq); pr_debug("Added buffer head %i to %p\n", head, vq);
END_USE(vq); END_USE(vq);
/* If we're indirect, we can fit many (assuming not OOM). */
if (vq->indirect)
return vq->num_free ? vq->vring.num : 0;
return vq->num_free; return vq->num_free;
} }
EXPORT_SYMBOL_GPL(virtqueue_add_buf_gfp); EXPORT_SYMBOL_GPL(virtqueue_add_buf_gfp);

View File

@ -517,7 +517,7 @@ static inline void __module_get(struct module *module)
#define symbol_put_addr(p) do { } while(0) #define symbol_put_addr(p) do { } while(0)
#endif /* CONFIG_MODULE_UNLOAD */ #endif /* CONFIG_MODULE_UNLOAD */
int use_module(struct module *a, struct module *b); int ref_module(struct module *a, struct module *b);
/* This is a #define so the string doesn't get put in every .o file */ /* This is a #define so the string doesn't get put in every .o file */
#define module_name(mod) \ #define module_name(mod) \