Hi Florian,
On Wed, Sep 11, 2013 at 11:26:03PM +0200, Florian Echtler wrote:
> +
> + /* allocate memory for our device state and initialize it */
> + sur40 = kzalloc(sizeof(struct sur40_state), GFP_KERNEL);
> + poll_dev = input_allocate_polled_device();
> + if (!sur40 || !poll_dev)
> + return -ENOMEM;
You are leaking memory here.
> +
> + /* setup polled input device control struct */
> + poll_dev->private = sur40;
> + poll_dev->poll_interval = POLL_INTERVAL;
> + poll_dev->open = sur40_open;
> + poll_dev->poll = sur40_poll;
> + poll_dev->close = sur40_close;
> +
> + /* setup regular input device struct */
> + sur40_input_setup(poll_dev->input);
> +
> + poll_dev->input->name = "Samsung SUR40";
> + usb_to_input_id(usbdev, &(poll_dev->input->id));
> + usb_make_path(usbdev, sur40->phys, sizeof(sur40->phys));
> + strlcat(sur40->phys, "/input0", sizeof(sur40->phys));
> + poll_dev->input->phys = sur40->phys;
> +
> + sur40->usbdev = usbdev;
> + sur40->input = poll_dev;
> +
> + /* use the bulk-in endpoint tested above */
> + sur40->bulk_in_size = le16_to_cpu(endpoint->wMaxPacketSize);
> + sur40->bulk_in_epaddr = endpoint->bEndpointAddress;
> + sur40->bulk_in_buffer = kmalloc(2 * sur40->bulk_in_size, GFP_KERNEL);
> + if (!sur40->bulk_in_buffer) {
> + dev_err(&interface->dev, "Unable to allocate input buffer.");
> + sur40_delete(sur40);
> + return -ENOMEM;
> + }
> +
> + result = input_register_polled_device(poll_dev);
> + if (result) {
> + dev_err(&interface->dev,
> + "Unable to register polled input device.");
> + sur40_delete(sur40);
> + return result;
> + }
> +
> + /* we can register the device now, as it is ready */
> + usb_set_intfdata(interface, sur40);
> + dev_info(&interface->dev, "%s now attached\n", DRIVER_DESC);
dev_dbg() if you must.
> +
> + return 0;
> +}
> +
> +/* unregister device & clean up */
> +static void sur40_disconnect(struct usb_interface *interface)
> +{
> + struct sur40_state *sur40 = usb_get_intfdata(interface);
> +
> + input_unregister_polled_device(sur40->input);
> +
> + usb_set_intfdata(interface, NULL);
> +
> + sur40_delete(sur40);
> +
> + dev_info(&interface->dev, "%s now disconnected\n", DRIVER_DESC);
Here as well.
Thanks.
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html