mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: Johan Hovold <johan@kernel.org>
Cc: Marc Ferland <ferlandm@amotus.ca>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] gnss: add USB support
Date: Mon, 20 Dec 2021 13:49:23 +0100	[thread overview]
Message-ID: <091d25b4-cfa5-c702-144a-8cfdb70b7f42@suse.com> (raw)
In-Reply-To: <20211220111901.23206-2-johan@kernel.org>


On 20.12.21 12:19, Johan Hovold wrote:
> +static int gnss_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
> +{
> +	struct usb_device *udev = interface_to_usbdev(intf);
> +	struct usb_endpoint_descriptor *in, *out;
> +	struct gnss_device *gdev;
> +	struct gnss_usb *gusb;
> +	struct urb *urb;
> +	size_t buf_len;
> +	void *buf;
> +	int ret;
> +
> +	ret = usb_find_common_endpoints(intf->cur_altsetting, &in, &out, NULL,
> +			NULL);
> +	if (ret)
> +		return ret;
> +
> +	gusb = kzalloc(sizeof(*gusb), GFP_KERNEL);
> +	if (!gusb)
> +		return -ENOMEM;
> +
> +	gdev = gnss_allocate_device(&intf->dev);
> +	if (!gdev) {
> +		ret = -ENOMEM;
> +		goto err_free_gusb;
> +	}
> +
> +	gdev->ops = &gnss_usb_gnss_ops;
> +	gdev->type = GNSS_TYPE_NMEA;
> +	gnss_set_drvdata(gdev, gusb);
> +
> +	urb = usb_alloc_urb(0, GFP_KERNEL);
> +	if (!urb)
> +			goto err_put_gdev;

The value of 'ret' here is the result of
usb_find_common_endpoints(), hence 0 due to the prior test.

> +
> +	buf_len = max(usb_endpoint_maxp(in), GNSS_USB_READ_BUF_LEN);
> +
> +	buf = kzalloc(buf_len, GFP_KERNEL);
> +	if (!buf)
> +		goto err_free_urb;
> +
> +	usb_fill_bulk_urb(urb, udev,
> +			usb_rcvbulkpipe(udev, usb_endpoint_num(in)),
> +			buf, buf_len, gnss_usb_rx_complete, gusb);
> +
> +	gusb->intf = intf;
> +	gusb->udev = udev;
> +	gusb->gdev = gdev;
> +	gusb->read_urb = urb;
> +	gusb->write_pipe = usb_sndbulkpipe(udev, usb_endpoint_num(out));
> +
> +	ret = gnss_register_device(gdev);
> +	if (ret)
> +		goto err_free_buf;
> +
> +	usb_set_intfdata(intf, gusb);
> +
> +	return 0;
> +
> +err_free_buf:
> +	kfree(buf);
> +err_free_urb:
> +	usb_free_urb(urb);
> +err_put_gdev:
> +	gnss_put_device(gdev);
> +err_free_gusb:
> +	kfree(gusb);
> +
> +	return ret;
Yet you return it in the error case and subsequent error cases..

    HTH
        Oliver


  reply	other threads:[~2021-12-20 12:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-20 11:18 [PATCH 0/2] " Johan Hovold
2021-12-20 11:19 ` [PATCH 1/2] " Johan Hovold
2021-12-20 12:49   ` Oliver Neukum [this message]
2021-12-20 13:25     ` Johan Hovold
2021-12-20 11:19 ` [PATCH 2/2] gnss: usb: add support for Sierra Wireless XM1210 Johan Hovold
2021-12-20 19:04   ` Marc Ferland
2021-12-22 14:46     ` Johan Hovold
2021-12-20 12:15 ` [PATCH 0/2] gnss: add USB support Greg KH
2021-12-20 13:26   ` Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=091d25b4-cfa5-c702-144a-8cfdb70b7f42@suse.com \
    --to=oneukum@suse.com \
    --cc=ferlandm@amotus.ca \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®