From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6249367928124211200 Date: Tue, 9 Feb 2016 14:20:38 -0800 (PST) From: Janani Ravichandran To: outreachy-kernel Cc: janani.rvchndrn@gmail.com Message-Id: <37a3f0ea-26e5-4d78-8730-81b7ed756644@googlegroups.com> In-Reply-To: References: <20160210013122.GA12148@janani-Inspiron-3521> Subject: Re: [Outreachy kernel] [PATCH v2] staging: rtl8192u: Use kmalloc_array instead of kmalloc MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_6724_415573740.1455056438241" X-Google-Token: ELbM6bUFob52xogB1G40 X-Google-IP: 72.231.208.13 ------=_Part_6724_415573740.1455056438241 Content-Type: multipart/alternative; boundary="----=_Part_6725_2139559765.1455056438241" ------=_Part_6725_2139559765.1455056438241 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On Tuesday, 9 February 2016 17:01:18 UTC-5, Julia Lawall wrote: > > > > On Tue, 9 Feb 2016, Janani Ravichandran wrote: > > > Use kmalloc_array instead of kmalloc for arrays. Coccinelle patch used: > > > > @@ > > expression E, F; > > constant FLAG; > > @@ > > > > - kmalloc(E*F, FLAG) > > + kmalloc_array(E, F, FLAG) > > Actually, your patch doesn't do exactly this. Your patch (correctly) has > E and F switched in the call to kmalloc_array. > I actually used the semantic patch to find instances where the conversion could be applied, then looked at the declaration of kmalloc_array to determine the correct order of arguments and did the change manually to make sure the number of elements was the first argument and the size of the element was the second argument. Please let me know if I should change anything here. Thank you! Janani > > > > > Signed-off-by: Janani Ravichandran > > > --- > > Changes since v1: > > * Corrected an error in commit message. > > "an error" is not very explicit. > > julia > > > drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c > b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c > > index 28ad63a..fb344d1 100644 > > --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c > > +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c > > @@ -601,8 +601,8 @@ static void RxReorderIndicatePacket(struct > ieee80211_device *ieee, > > bool bMatchWinStart = false, bPktInBuf = > false; > > IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is > %d,pTS->RxIndicateSeq is %d, WinSize is > %d\n",__func__,SeqNum,pTS->RxIndicateSeq,WinSize); > > > > - prxbIndicateArray = kmalloc(sizeof(struct ieee80211_rxb *) * > > - REORDER_WIN_SIZE, GFP_KERNEL); > > + prxbIndicateArray = kmalloc_array(RECORDER_WIN_SIZE, > > + sizeof(struct ieee80211_rxb *), GFP_KERNEL); > > if (!prxbIndicateArray) > > return; > > > > -- > > 2.5.0 > > > > -- > > You received this message because you are subscribed to the Google > Groups "outreachy-kernel" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to outreachy-kern...@googlegroups.com . > > To post to this group, send email to outreach...@googlegroups.com > . > > To view this discussion on the web visit > https://groups.google.com/d/msgid/outreachy-kernel/20160210013122.GA12148%40janani-Inspiron-3521. > > > For more options, visit https://groups.google.com/d/optout. > > > ------=_Part_6725_2139559765.1455056438241 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Tuesday, 9 February 2016 17:01:18 UTC-5, Julia = Lawall wrote:


On Tue, 9 Feb 2016, Janani Ravichandran wrote:

> Use kmalloc_array instead of kmalloc for arrays. Coccinelle patch = used:
>=20
> @@
> expression E, F;
> constant FLAG;
> @@
>=20
> - kmalloc(E*F, FLAG)
> + kmalloc_array(E, F, FLAG)

Actually, your patch doesn't do exactly this. =C2=A0Your patch (cor= rectly) has=20
E and F switched in the call to kmalloc_array.
I actually used the semantic patch to find instances = where the conversion could be applied,
then looked at the declaration o= f kmalloc_array to determine the correct order of
arguments and did the= change manually to make sure the number of elements was the
first argu= ment and the size of the element was the second argument.

Please let= me know if I should change anything here. Thank you!

Janani

>=20
> Signed-off-by: Janani Ravichandran <janani....@gmail.com>
> ---
> Changes since v1:
> =C2=A0* Corrected an error in commit message.

"an error" is not very explicit.

julia

> =C2=A0drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 += +--
> =C2=A01 file changed, 2 insertions(+), 2 deletions(-)
>=20
> diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.= c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
> index 28ad63a..fb344d1 100644
> --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
> +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
> @@ -601,8 +601,8 @@ static void RxReorderIndicatePacket(struct iee= e80211_device *ieee,
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bool=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bMatchW= inStart =3D false, bPktInBuf =3D false;
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0IEEE80211_DE= BUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq i= s %d, WinSize is %d\n",__func__,SeqNum,pTS->RxIndicateSeq,WinS= ize);
> =C2=A0
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0prxbIndicateArray= =3D kmalloc(sizeof(struct ieee80211_rxb *) *
> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0REORDER_WIN_SIZE, GFP_KERNEL);
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0prxbIndicateArray= =3D kmalloc_array(RECORDER_WIN_SIZE,
> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0sizeof(struct ieee80211_rxb *), GFP_KERNEL);
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (!prxbInd= icateArray)
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return;
> =C2=A0
> --=20
> 2.5.0
>=20
> --=20
> You received this message because you are subscribed to the Google= Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, = send an email to outreachy-kern...@googlegroups.com.
> To post to this group, send email to outreach...@googlegroups.com<= /a>.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/= outreachy-kernel/20160210013122.GA12148%40janani-Inspiron-3521.
> For more options, visit
https://groups.go= ogle.com/d/optout.
>=20
------=_Part_6725_2139559765.1455056438241-- ------=_Part_6724_415573740.1455056438241--