All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Foster Snowhill <forst@pen.gy>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>
Cc: Georgi Valkov <gvalkov@gmail.com>,
	Simon Horman <simon.horman@corigine.com>,
	 Jan Kiszka <jan.kiszka@siemens.com>,
	linux-usb@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net-next v3 2/2] usbnet: ipheth: add CDC NCM support
Date: Tue, 30 May 2023 12:58:06 +0200	[thread overview]
Message-ID: <e7159f2e39e79e51da123d09cfbcc21411dad544.camel@redhat.com> (raw)
In-Reply-To: <20230527130309.34090-2-forst@pen.gy>

Hi,

On Sat, 2023-05-27 at 15:03 +0200, Foster Snowhill wrote:
> @@ -116,12 +124,12 @@ static int ipheth_alloc_urbs(struct ipheth_device *iphone)
>  	if (rx_urb == NULL)
>  		goto free_tx_urb;
>  
> -	tx_buf = usb_alloc_coherent(iphone->udev, IPHETH_BUF_SIZE,
> +	tx_buf = usb_alloc_coherent(iphone->udev, IPHETH_TX_BUF_SIZE,
>  				    GFP_KERNEL, &tx_urb->transfer_dma);
>  	if (tx_buf == NULL)
>  		goto free_rx_urb;
>  
> -	rx_buf = usb_alloc_coherent(iphone->udev, IPHETH_BUF_SIZE + IPHETH_IP_ALIGN,
> +	rx_buf = usb_alloc_coherent(iphone->udev, IPHETH_RX_BUF_SIZE,
>  				    GFP_KERNEL, &rx_urb->transfer_dma);
>  	if (rx_buf == NULL)
>  		goto free_tx_buf;

Here the driver already knows if the device is in NCM or legacy mode,
so perhaps we could select the buffer size accordingly? You would
probably need to store the actual buffer size somewhere to keep the
buffer handling consistent and simple in later code.

> @@ -373,12 +489,10 @@ static netdev_tx_t ipheth_tx(struct sk_buff *skb, struct net_device *net)
>  	}
>  
>  	memcpy(dev->tx_buf, skb->data, skb->len);
> -	if (skb->len < IPHETH_BUF_SIZE)
> -		memset(dev->tx_buf + skb->len, 0, IPHETH_BUF_SIZE - skb->len);
>  
>  	usb_fill_bulk_urb(dev->tx_urb, udev,
>  			  usb_sndbulkpipe(udev, dev->bulk_out),
> -			  dev->tx_buf, IPHETH_BUF_SIZE,
> +			  dev->tx_buf, skb->len,
>  			  ipheth_sndbulk_callback,
>  			  dev);
>  	dev->tx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;

This chunk looks unrelated from NCM support, and unconditionally
changes the established behaviour even with legacy mode, why?

Does that works even with old(er) devices?

Thanks,

Paolo


  reply	other threads:[~2023-05-30 10:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-27 13:03 [PATCH net-next v3 1/2] usbnet: ipheth: fix risk of NULL pointer deallocation Foster Snowhill
2023-05-27 13:03 ` [PATCH net-next v3 2/2] usbnet: ipheth: add CDC NCM support Foster Snowhill
2023-05-30 10:58   ` Paolo Abeni [this message]
2023-05-31 13:14     ` George Valkov
2023-05-31 15:10     ` Foster Snowhill
2023-06-01  8:09       ` Paolo Abeni
2023-05-27 14:50 ` [PATCH net-next v3 1/2] usbnet: ipheth: fix risk of NULL pointer deallocation Simon Horman
2023-05-30 11:02 ` Paolo Abeni
2023-05-30 11:09   ` George Valkov
2023-05-30 11:11   ` George Valkov
2023-05-30 13:41     ` Paolo Abeni

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=e7159f2e39e79e51da123d09cfbcc21411dad544.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=forst@pen.gy \
    --cc=gvalkov@gmail.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kuba@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=simon.horman@corigine.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.