RE: [PATCH v5 2/3] usb: typec: ucsi: do not allocate one extra unused connector

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>
> Sent: Monday, April 25, 2022 4:14 PM
> To: Linyu Yuan (QUIC) <quic_linyyuan@xxxxxxxxxxx>
> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>; linux-
> usb@xxxxxxxxxxxxxxx; Jack Pham (QUIC) <quic_jackp@xxxxxxxxxxx>
> Subject: Re: [PATCH v5 2/3] usb: typec: ucsi: do not allocate one extra
> unused connector
> 
> 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.

Sure, thanks, will merge next version.

> 
> > Signed-off-by: Linyu Yuan <quic_linyyuan@xxxxxxxxxxx>
> > ---
> > 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




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux