From: Jes Sorensen <jes.sorensen@gmail.com>
To: Vaishali Thakkar <vthakkar1994@gmail.com>,
Arnd Bergmann <arnd@arndb.de>
Cc: outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Use put_unaligned_le16
Date: Tue, 17 Feb 2015 14:12:43 -0500 [thread overview]
Message-ID: <54E392AB.2020405@gmail.com> (raw)
In-Reply-To: <CAK-LDbLXghCwRVHATPSCcVU0-pH+_tQdTnWTN-Kykpzv5AyOWw@mail.gmail.com>
On 02/17/15 05:11, Vaishali Thakkar wrote:
> On Tue, Feb 17, 2015 at 2:32 PM, Arnd Bergmann <arnd@arndb.de> wrote:
>> On Tuesday 17 February 2015 10:12:57 Vaishali Thakkar wrote:
>>> diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c
>>> index da19145..0b7b156 100644
>>> --- a/drivers/staging/rtl8188eu/core/rtw_ap.c
>>> +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
>>> @@ -81,8 +81,6 @@ static void update_BCNTIM(struct adapter *padapter)
>>> __le16 tim_bitmap_le;
>>> uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen;
>>>
>>> - tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap);
>>> -
>>> p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_);
>>> if (p != NULL && tim_ielen > 0) {
>>> tim_ielen += 2;
>>> @@ -139,7 +137,7 @@ static void update_BCNTIM(struct adapter *padapter)
>>> if (tim_ielen == 4) {
>>> *dst_ie++ = *(u8 *)&tim_bitmap_le;
>>> } else if (tim_ielen == 5) {
>>> - memcpy(dst_ie, &tim_bitmap_le, 2);
>>> + put_unaligned_le16(pstapriv->tim_bitmap, dst_ie);
>>> dst_ie += 2;
>>
>> I think you are introducing the use of an uninitialized variable here, when
>> tim_bitmap_le is accessed first.
>>
>> You should always compile the code you change to check for new warnings,
>> and when you remove the use of a variable, check who else is using it
>> and if it can be removed. In this case, I'd suggest removing the
>> tim_bitmap_le variable entirely and fixing the other use as well.
>
> I compiled the code before sending this. But it seems something went
> wrong from my side.I am sorry for this. Can you please tell me which errors are
> introduced by this patch as it is stillnot showing me any errors??
>
> Also, here this Coccinelle semantic patch performs check for the variable
> and if it is not used anywhere else then it removes the variable.Here,
> in this case
> tim_bitmap_le variable is used " *dst_ie++ = *(u8 *)&tim_bitmap_le;"
> here. So, do
> you want me to fix this line and then remove this variable?? I am
> sorry but I am
> confused here that's why asking again.
Your use of put_unaligned_le16() if good, the main issue is the above
assignment as you mention. Since you got rid of the tim_bitmap_le =
portion, the *dst_ie++ = is going to assigning random garbage since
tim_bitmap_le is not set.
One way to solve the problem would be to make that line say
if (tim_ielen == 4) {
- *dst_ie++ = *(u8 *)&tim_bitmap_le;
+ *dst_ie++ = pstapriv->tim_bitmap & 0xff;
} else if (tim_ielen == 5) {
- memcpy(dst_ie, &tim_bitmap_le, 2);
+ put_unaligned_le16(pstapriv->tim_bitmap, dst_ie);
and hopefully eliminate the tim_bitmap_le variable completely.
Jes
next prev parent reply other threads:[~2015-02-17 19:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-17 4:42 [PATCH] Staging: rtl8188eu: Use put_unaligned_le16 Vaishali Thakkar
2015-02-17 9:02 ` [Outreachy kernel] " Arnd Bergmann
2015-02-17 10:11 ` Vaishali Thakkar
2015-02-17 19:12 ` Jes Sorensen [this message]
2015-02-18 1:32 ` Vaishali Thakkar
2015-02-18 10:50 ` Arnd Bergmann
2015-02-18 17:10 ` Jes Sorensen
2015-02-18 18:08 ` Vaishali Thakkar
2015-02-18 22:31 ` Jes Sorensen
2015-02-19 3:05 ` Vaishali Thakkar
2015-02-19 8:28 ` Arnd Bergmann
2015-02-19 8:43 ` Vaishali Thakkar
2015-02-20 12:01 ` Jes Sorensen
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=54E392AB.2020405@gmail.com \
--to=jes.sorensen@gmail.com \
--cc=arnd@arndb.de \
--cc=outreachy-kernel@googlegroups.com \
--cc=vthakkar1994@gmail.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.