public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Linyu Yuan <quic_linyyuan@quicinc.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, Jack Pham <quic_jackp@quicinc.com>
Subject: Re: [PATCH v5 2/3] usb: typec: ucsi: do not allocate one extra unused connector
Date: Mon, 25 Apr 2022 11:13:41 +0300	[thread overview]
Message-ID: <YmZYNWewOiHNu+9D@kuha.fi.intel.com> (raw)
In-Reply-To: <1650597022-19793-3-git-send-email-quic_linyyuan@quicinc.com>

On Fri, Apr 22, 2022 at 11:10:21AM +0800, Linyu Yuan wrote:
> In ucsi_init(), it allocate number of (ucsi->cap.num_connectors + 1)
> connectors, there is one extra as the ending.
> ucsi_unregister_connectors() is safe to unregister all ucsi connectors
> according ucsi->cap.num_connectors.
> 
> Let's remove the extra one connector to save memory.

Maybe you could just merge this one into the first patch.

> Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
> ---
> v2: new change
> v3: no change
> v4: fix a typo extral -> extra in commit description
> v5: update commit description
> 
>  drivers/usb/typec/ucsi/ucsi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index af9a2a1..ce9192e 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1251,7 +1251,7 @@ static int ucsi_init(struct ucsi *ucsi)
>  	}
>  
>  	/* Allocate the connectors. Released in ucsi_unregister() */
> -	ucsi->connector = kcalloc(ucsi->cap.num_connectors + 1,
> +	ucsi->connector = kcalloc(ucsi->cap.num_connectors,
>  				  sizeof(*ucsi->connector), GFP_KERNEL);
>  	if (!ucsi->connector) {
>  		ret = -ENOMEM;
> -- 
> 2.7.4

thanks,

-- 
heikki

  reply	other threads:[~2022-04-25  8:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-22  3:10 [PATCH v5 0/3] usb: typec: ucsi: allow retry to find role switch Linyu Yuan
2022-04-22  3:10 ` [PATCH v5 1/3] usb: typec: ucsi: add a common function ucsi_unregister_connectors() Linyu Yuan
2022-04-25  8:09   ` Heikki Krogerus
2022-04-25  8:23     ` Linyu Yuan (QUIC)
2022-04-22  3:10 ` [PATCH v5 2/3] usb: typec: ucsi: do not allocate one extra unused connector Linyu Yuan
2022-04-25  8:13   ` Heikki Krogerus [this message]
2022-04-25  8:23     ` Linyu Yuan (QUIC)
2022-04-22  3:10 ` [PATCH v5 3/3] usb: typec: ucsi: Wait for the USB role switches Linyu Yuan
2022-04-25  8:14   ` Heikki Krogerus

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=YmZYNWewOiHNu+9D@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=quic_jackp@quicinc.com \
    --cc=quic_linyyuan@quicinc.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox