linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* re: iwlwifi: refactor the SAR tables from mvm to acpi
@ 2019-12-20  0:02 Colin Ian King
  2019-12-20  5:40 ` Luciano Coelho
  0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2019-12-20  0:02 UTC (permalink / raw)
  To: Johannes Berg, Emmanuel Grumbach, Luca Coelho,
	Intel Linux Wireless, Kalle Valo, David S. Miller, Ihab Zhaika,
	Shahar S Matityahu, linux-wireless, netdev
  Cc: linux-kernel

Hi,

Static analysis with Coverity has detected a potential issue with the
following commit:

commit 39c1a9728f938c7255ce507c8d56b73e8a4ebddf
Author: Ihab Zhaika <ihab.zhaika@intel.com>
Date:   Fri Nov 15 09:28:11 2019 +0200

    iwlwifi: refactor the SAR tables from mvm to acpi


in function iwl_sar_get_ewrd_table() we have an array index pos being
initialized to 3 and then incremented each time a loop iterates:

        for (i = 0; i < n_profiles; i++) {
                /* the tables start at element 3 */
                int pos = 3;

                /* The EWRD profiles officially go from 2 to 4, but we
                 * save them in sar_profiles[1-3] (because we don't
                 * have profile 0).  So in the array we start from 1.
                 */
                ret = iwl_sar_set_profile(&wifi_pkg->package.elements[pos],
                                          &fwrt->sar_profiles[i + 1],
                                          enabled);
                if (ret < 0)
                        break;

                /* go to the next table */
                pos += ACPI_SAR_TABLE_SIZE;
        }

So, each iteration is always accessing package.elements[3]. I'm not sure
if that is intentional. If it is, then the increment of pos is not
required.  Either way, it's not clear what the original intention is.

Colin

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: iwlwifi: refactor the SAR tables from mvm to acpi
  2019-12-20  0:02 iwlwifi: refactor the SAR tables from mvm to acpi Colin Ian King
@ 2019-12-20  5:40 ` Luciano Coelho
  0 siblings, 0 replies; 2+ messages in thread
From: Luciano Coelho @ 2019-12-20  5:40 UTC (permalink / raw)
  To: Colin Ian King, Johannes Berg, Emmanuel Grumbach,
	Intel Linux Wireless, Kalle Valo, David S. Miller, Ihab Zhaika,
	Shahar S Matityahu, linux-wireless, netdev
  Cc: linux-kernel

On Fri, 2019-12-20 at 00:02 +0000, Colin Ian King wrote:
> Hi,
> 
> Static analysis with Coverity has detected a potential issue with the
> following commit:
> 
> commit 39c1a9728f938c7255ce507c8d56b73e8a4ebddf
> Author: Ihab Zhaika <ihab.zhaika@intel.com>
> Date:   Fri Nov 15 09:28:11 2019 +0200
> 
>     iwlwifi: refactor the SAR tables from mvm to acpi
> 
> 
> in function iwl_sar_get_ewrd_table() we have an array index pos being
> initialized to 3 and then incremented each time a loop iterates:
> 
>         for (i = 0; i < n_profiles; i++) {
>                 /* the tables start at element 3 */
>                 int pos = 3;
> 
>                 /* The EWRD profiles officially go from 2 to 4, but we
>                  * save them in sar_profiles[1-3] (because we don't
>                  * have profile 0).  So in the array we start from 1.
>                  */
>                 ret = iwl_sar_set_profile(&wifi_pkg->package.elements[pos],
>                                           &fwrt->sar_profiles[i + 1],
>                                           enabled);
>                 if (ret < 0)
>                         break;
> 
>                 /* go to the next table */
>                 pos += ACPI_SAR_TABLE_SIZE;
>         }
> 
> So, each iteration is always accessing package.elements[3]. I'm not sure
> if that is intentional. If it is, then the increment of pos is not
> required.  Either way, it's not clear what the original intention is.

Good catch, thanks! We'll fix it.

--
Cheers,
Luca.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-20  5:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-20  0:02 iwlwifi: refactor the SAR tables from mvm to acpi Colin Ian King
2019-12-20  5:40 ` Luciano Coelho

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).