[PATCH 0/3] iwlwifi: cosmetic fixes

2017-10-04 Thread Christoph Böhmwalder
Fix several code style issues, some of which were reported by checkpatch.pl.

The changes are:
* One instance of an `int` variable being used in a boolean context, chaned to
  use the more appropriate `bool` type.
* One very minor fix, removing a newline between a function definition and its
  associated `static` keyword
* One fix wrapping a macro in curly braces


Christoph Böhmwalder (3):
  wireless: iwlwifi: use bool instead of int
  wireless: iwlwifi: function definition cosmetic fix
  wireless: iwlwifi: wrap macro into braces

 drivers/net/wireless/intel/iwlwifi/iwl-io.c |  2 +-
 drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c | 16 +++-
 2 files changed, 8 insertions(+), 10 deletions(-)

-- 
2.13.5



[PATCH 2/3] wireless: iwlwifi: function definition cosmetic fix

2017-10-04 Thread Christoph Böhmwalder
Separate the function from the previous definition with a newline and
put the `static` keyword on the same line, as it just looks nicer.

Signed-off-by: Christoph Böhmwalder 
---
 drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c
index 0eb815ae97e8..249ee1c7b02f 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c
@@ -325,8 +325,8 @@ static u16 channel_id_to_txp(struct iwl_phy_db *phy_db, u16 
ch_id)
}
return 0xff;
 }
-static
-int iwl_phy_db_get_section_data(struct iwl_phy_db *phy_db,
+
+static int iwl_phy_db_get_section_data(struct iwl_phy_db *phy_db,
u32 type, u8 **data, u16 *size, u16 ch_id)
 {
struct iwl_phy_db_entry *entry;
-- 
2.13.5



[PATCH 1/3] wireless: iwlwifi: use bool instead of int

2017-10-04 Thread Christoph Böhmwalder
Change a usage of int in a boolean context to use the bool type instead, as it
makes the intent of the function clearer and helps clarify its semantics.

Also eliminate the if/else and just return the boolean result directly,
making the code more readable.

Signed-off-by: Christoph Böhmwalder 
---
 drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c
index b7cd813ba70f..0eb815ae97e8 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c
@@ -267,14 +267,12 @@ int iwl_phy_db_set_section(struct iwl_phy_db *phy_db,
 }
 IWL_EXPORT_SYMBOL(iwl_phy_db_set_section);
 
-static int is_valid_channel(u16 ch_id)
+static bool is_valid_channel(u16 ch_id)
 {
-   if (ch_id <= 14 ||
-   (36 <= ch_id && ch_id <= 64 && ch_id % 4 == 0) ||
-   (100 <= ch_id && ch_id <= 140 && ch_id % 4 == 0) ||
-   (145 <= ch_id && ch_id <= 165 && ch_id % 4 == 1))
-   return 1;
-   return 0;
+   return (ch_id <= 14 ||
+  (36 <= ch_id && ch_id <= 64 && ch_id % 4 == 0) ||
+  (100 <= ch_id && ch_id <= 140 && ch_id % 4 == 0) ||
+  (145 <= ch_id && ch_id <= 165 && ch_id % 4 == 1));
 }
 
 static u8 ch_id_to_ch_index(u16 ch_id)
-- 
2.13.5



[PATCH 3/3] wireless: iwlwifi: wrap macro into braces

2017-10-04 Thread Christoph Böhmwalder
Macros should always be wrapped in braces, so fix this instance.

Signed-off-by: Christoph Böhmwalder 
---
 drivers/net/wireless/intel/iwlwifi/iwl-io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-io.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-io.c
index efb1998dcabd..0211963b3e71 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-io.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-io.c
@@ -252,7 +252,7 @@ IWL_EXPORT_SYMBOL(iwl_force_nmi);
 
 static const char *get_rfh_string(int cmd)
 {
-#define IWL_CMD(x) case x: return #x
+#define IWL_CMD(x) { case x: return #x; }
 #define IWL_CMD_MQ(arg, reg, q) { if (arg == reg(q)) return #reg; }
 
int i;
-- 
2.13.5



Re: [PATCH] ath9k: fix tx99 potential info leak

2017-09-26 Thread Christoph Böhmwalder

>>
>> +buf[len] = '\0';
>> +
> 
> I think it would be more appropriate here to check if buf[len] == '\0' and 
> return an error otherwise.

Nevermind, I just had a closer look and I actually think your approach
is fine. I hadn't considered the possibility of someone deliberately
passing a non-null-terminated string with a specific length.

>> Signed-off-by: Miaoqing Pan 

Reviewed-by: Christoph Böhmwalder 

-- 
Regards,
Christoph



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] ath9k: fix tx99 potential info leak

2017-09-26 Thread Christoph Böhmwalder
Am 27. September 2017 03:13:34 MESZ schrieb miaoq...@codeaurora.org:
>From: Miaoqing Pan 
>
>When the user sets count to zero the string buffer would remain
>completely uninitialized which causes the kernel to parse its
>own stack data, potentially leading to an info leak. In addition
>to that, the string might be not terminated properly when the
>user data does not contain a 0-terminator.
>
>Signed-off-by: Miaoqing Pan 
>---
> drivers/net/wireless/ath/ath9k/tx99.c | 5 +
> 1 file changed, 5 insertions(+)
>
>diff --git a/drivers/net/wireless/ath/ath9k/tx99.c
>b/drivers/net/wireless/ath/ath9k/tx99.c
>index 49ed1af..fe3a826 100644
>--- a/drivers/net/wireless/ath/ath9k/tx99.c
>+++ b/drivers/net/wireless/ath/ath9k/tx99.c
>@@ -179,6 +179,9 @@ static ssize_t write_file_tx99(struct file *file,
>const char __user *user_buf,
>   ssize_t len;
>   int r;
> 
>+  if (count < 1)
>+  return -EINVAL;
>+
>   if (sc->cur_chan->nvifs > 1)
>   return -EOPNOTSUPP;
> 
>@@ -186,6 +189,8 @@ static ssize_t write_file_tx99(struct file *file,
>const char __user *user_buf,
>   if (copy_from_user(buf, user_buf, len))
>   return -EFAULT;
> 
>+  buf[len] = '\0';
>+

I think it would be more appropriate here to check if buf[len] == '\0' and 
return an error otherwise.

>   if (strtobool(buf, &start))
>   return -EINVAL;
> 
>-- 
>1.9.1


--
Regards,
Christoph


Re: [PATCH RESEND] wireless: iwlwifi: fix minor code style issues

2017-09-25 Thread Christoph Böhmwalder
> Why are you already resending this?

Sorry, I guess I was too impatient. I also messed up the spelling in a
"To:" line and forgot triv...@kernel.org the first time I sent it, so I
figured I'd just fix it in a resend.

I'll make sure to wait a little longer next time.

--
Regards,
Christoph



signature.asc
Description: OpenPGP digital signature


[PATCH RESEND] wireless: iwlwifi: fix minor code style issues

2017-09-25 Thread Christoph Böhmwalder
Fixes three trivial issues as reported by checkpatch.pl, namely two
switch/case indentation issues and one alignment issue in a multiline
comment.

Signed-off-by: Christoph Böhmwalder 
---
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
index 99676d6c4713..ccdb247d68c5 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
@@ -832,7 +832,7 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
capa->standard_phy_calibration_size =
le32_to_cpup((__le32 *)tlv_data);
break;
-case IWL_UCODE_TLV_SEC_RT:
+   case IWL_UCODE_TLV_SEC_RT:
iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR,
tlv_len);
drv->fw.type = IWL_FW_MVM;
@@ -864,7 +864,7 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
FW_PHY_CFG_RX_CHAIN) >>
FW_PHY_CFG_RX_CHAIN_POS;
break;
-case IWL_UCODE_TLV_SECURE_SEC_RT:
+   case IWL_UCODE_TLV_SECURE_SEC_RT:
iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR,
tlv_len);
drv->fw.type = IWL_FW_MVM;
@@ -1335,7 +1335,8 @@ static void iwl_req_fw_callback(const struct
firmware *ucode_raw, void *context)
/* Runtime instructions and 2 copies of data:
 * 1) unmodified from disk
-* 2) backup cache for save/restore during power-downs */
+* 2) backup cache for save/restore during power-downs
+*/
for (i = 0; i < IWL_UCODE_TYPE_MAX; i++)
if (iwl_alloc_ucode(drv, pieces, i))
goto out_free_fw;
-- 
2.13.5




signature.asc
Description: OpenPGP digital signature


[PATCH] wireless: iwlwifi: fix minor code style issues

2017-09-23 Thread Christoph Böhmwalder
Fixes three trivial issues as reported by checkpatch.pl, namely two
switch/case indentation issues and one alignment issue in a multiline comment.

Signed-off-by: Christoph Böhmwalder 
---
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
index 99676d6c4713..ccdb247d68c5 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
@@ -832,7 +832,7 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
capa->standard_phy_calibration_size =
le32_to_cpup((__le32 *)tlv_data);
break;
-case IWL_UCODE_TLV_SEC_RT:
+   case IWL_UCODE_TLV_SEC_RT:
iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR,
tlv_len);
drv->fw.type = IWL_FW_MVM;
@@ -864,7 +864,7 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
FW_PHY_CFG_RX_CHAIN) >>
FW_PHY_CFG_RX_CHAIN_POS;
break;
-case IWL_UCODE_TLV_SECURE_SEC_RT:
+   case IWL_UCODE_TLV_SECURE_SEC_RT:
iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR,
tlv_len);
drv->fw.type = IWL_FW_MVM;
@@ -1335,7 +1335,8 @@ static void iwl_req_fw_callback(const struct firmware 
*ucode_raw, void *context)
 
/* Runtime instructions and 2 copies of data:
 * 1) unmodified from disk
-* 2) backup cache for save/restore during power-downs */
+* 2) backup cache for save/restore during power-downs
+*/
for (i = 0; i < IWL_UCODE_TYPE_MAX; i++)
if (iwl_alloc_ucode(drv, pieces, i))
goto out_free_fw;
-- 
2.13.5