Skip to contentSkip to conversation

NFC: fix attrs checks in netlink interface

PATCH Superseded Andy Shevchenko 4 participants 20 messages Jul 25, 2019 – Jul 29, 2019

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/14 NFC: fix attrs checks in netlink interface

From: Andrey Konovalov <[email protected]>

nfc_genl_deactivate_target() relies on the NFC_ATTR_TARGET_INDEX attribute being present, but doesn't check whether it is actually provided by the user. Same goes for nfc_genl_fw_download() and NFC_ATTR_FIRMWARE_NAME.

This patch adds appropriate checks.

Found with syzkaller.

---
 net/nfc/netlink.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/nfc/netlink.c +4 -2
index 4a30309bb67f..60fd2748d0ea 100644
@@ -970,7 +970,8 @@ static int nfc_genl_dep_link_down(struct sk_buff *skb, struct genl_info *info)
 	int rc;
 	u32 idx;
 
-	if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
+	if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
+	    !info->attrs[NFC_ATTR_TARGET_INDEX])
 		return -EINVAL;
 
 	idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
@@ -1018,7 +1019,8 @@ static int nfc_genl_llc_get_params(struct sk_buff *skb, struct genl_info *info)
 	struct sk_buff *msg = NULL;
 	u32 idx;
 
-	if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
+	if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
+	    !info->attrs[NFC_ATTR_FIRMWARE_NAME])
 		return -EINVAL;
 
 	idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
Signature · 1 line
2.20.1
#3 lore raw

PATCH v3 4/14 NFC: nxp-nci: Convert to use GPIO descriptor

Since we got rid of platform data, the driver may use GPIO descriptor directly.

---
 drivers/nfc/nxp-nci/core.c |  1 -
 drivers/nfc/nxp-nci/i2c.c  | 60 ++++++++++----------------------------
 2 files changed, 15 insertions(+), 46 deletions(-)
drivers/nfc/nxp-nci/core.c +0 -1
index aed18ca60170..a0ce95a287c5 100644
@@ -11,7 +11,6 @@
  */
 
 #include <linux/delay.h>
-#include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/nfc.h>
 
drivers/nfc/nxp-nci/i2c.c +15 -45

112 lines not on this page · raw message

Signature · 1 line
2.20.1
#1 lore raw

PATCH v3 2/14 NFC: nxp-nci: Add NXP1001 to the ACPI ID table

In reply to Andy Shevchenko

It seems a lot of laptops are equipped with NXP NFC300 chip with the ACPI ID NXP1001 as per DSDT.

Append it to the driver's ACPI ID table.

---
 drivers/nfc/nxp-nci/i2c.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nfc/nxp-nci/i2c.c +1 -0
index 4aeb3861b409..5db71869f04b 100644
@@ -396,6 +396,7 @@ MODULE_DEVICE_TABLE(of, of_nxp_nci_i2c_match);
 
 #ifdef CONFIG_ACPI
 static struct acpi_device_id acpi_id[] = {
+	{ "NXP1001" },
 	{ "NXP7471" },
 	{ },
 };
Signature · 1 line
2.20.1
#7 lore raw

PATCH v3 8/14 NFC: nxp-nci: Constify acpi_device_id

In reply to Andy Shevchenko

The content of acpi_device_id is not supposed to change at runtime. All functions working with acpi_device_id provided by <linux/acpi.h> work with const acpi_device_id. So mark the non-const structs as const.

---
 drivers/nfc/nxp-nci/i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/nxp-nci/i2c.c +1 -1
index bec9b1ea78e2..4e71962dc557 100644
@@ -330,7 +330,7 @@ static const struct of_device_id of_nxp_nci_i2c_match[] = {
 MODULE_DEVICE_TABLE(of, of_nxp_nci_i2c_match);
 
 #ifdef CONFIG_ACPI
-static struct acpi_device_id acpi_id[] = {
+static const struct acpi_device_id acpi_id[] = {
 	{ "NXP1001" },
 	{ "NXP7471" },
 	{ },
Signature · 1 line
2.20.1
#5 lore raw

PATCH v3 6/14 NFC: nxp-nci: Get rid of code duplication in ->probe()

In reply to Andy Shevchenko

Since OF and ACPI case almost the same get rid of code duplication by moving gpiod_get() calls directly to ->probe().

---
 drivers/nfc/nxp-nci/i2c.c | 68 +++++++++------------------------------
 1 file changed, 15 insertions(+), 53 deletions(-)
drivers/nfc/nxp-nci/i2c.c +15 -53
index 7344405feddf..6a627d1b6f85 100644
@@ -256,48 +256,10 @@ static const struct acpi_gpio_mapping acpi_nxp_nci_gpios[] = {
 	{ }
 };
 
-static int nxp_nci_i2c_parse_devtree(struct i2c_client *client)
-{
-	struct nxp_nci_i2c_phy *phy = i2c_get_clientdata(client);
-
-	phy->gpiod_en = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
-	if (IS_ERR(phy->gpiod_en)) {
-		nfc_err(&client->dev, "Failed to get EN gpio\n");
-		return PTR_ERR(phy->gpiod_en);
-	}
-
-	phy->gpiod_fw = devm_gpiod_get(&client->dev, "firmware", GPIOD_OUT_LOW);
-	if (IS_ERR(phy->gpiod_fw)) {
-		nfc_err(&client->dev, "Failed to get FW gpio\n");
-		return PTR_ERR(phy->gpiod_fw);
-	}
-
-	return 0;
-}
-
-static int nxp_nci_i2c_acpi_config(struct nxp_nci_i2c_phy *phy)
-{
-	struct i2c_client *client = phy->i2c_dev;
-	int r;
-
-	r = devm_acpi_dev_add_driver_gpios(&client->dev, acpi_nxp_nci_gpios);
-	if (r)
-		return r;
-
-	phy->gpiod_en = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
-	phy->gpiod_fw = devm_gpiod_get(&client->dev, "firmware", GPIOD_OUT_LOW);
-
-	if (IS_ERR(phy->gpiod_en) || IS_ERR(phy->gpiod_fw)) {
-		nfc_err(&client->dev, "No GPIOs\n");
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
 static int nxp_nci_i2c_probe(struct i2c_client *client,
 			    const struct i2c_device_id *id)
 {
+	struct device *dev = &client->dev;
 	struct nxp_nci_i2c_phy *phy;
 	int r;
 
@@ -317,20 +279,20 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
 	phy->i2c_dev = client;
 	i2c_set_clientdata(client, phy);
 
-	if (client->dev.of_node) {
-		r = nxp_nci_i2c_parse_devtree(client);
-		if (r < 0) {
-			nfc_err(&client->dev, "Failed to get DT data\n");
-			goto probe_exit;
-		}
-	} else if (ACPI_HANDLE(&client->dev)) {
-		r = nxp_nci_i2c_acpi_config(phy);
-		if (r < 0)
-			goto probe_exit;
-	} else {
-		nfc_err(&client->dev, "No platform data\n");
-		r = -EINVAL;
-		goto probe_exit;
+	r = devm_acpi_dev_add_driver_gpios(dev, acpi_nxp_nci_gpios);
+	if (r)
+		return r;
+
+	phy->gpiod_en = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
+	if (IS_ERR(phy->gpiod_en)) {
+		nfc_err(dev, "Failed to get EN gpio\n");
+		return PTR_ERR(phy->gpiod_en);
+	}
+
+	phy->gpiod_fw = devm_gpiod_get(dev, "firmware", GPIOD_OUT_LOW);
+	if (IS_ERR(phy->gpiod_fw)) {
+		nfc_err(dev, "Failed to get FW gpio\n");
+		return PTR_ERR(phy->gpiod_fw);
 	}
 
 	r = nxp_nci_probe(phy, &client->dev, &i2c_phy_ops,
Signature · 1 line
2.20.1
#6 lore raw

PATCH v3 7/14 NFC: nxp-nci: Get rid of useless label

In reply to Andy Shevchenko

Return directly in ->probe() since there no special cleaning is needed.

---
 drivers/nfc/nxp-nci/i2c.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/nfc/nxp-nci/i2c.c +4 -8
index 6a627d1b6f85..bec9b1ea78e2 100644
@@ -265,16 +265,13 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
 		nfc_err(&client->dev, "Need I2C_FUNC_I2C\n");
-		r = -ENODEV;
-		goto probe_exit;
+		return -ENODEV;
 	}
 
 	phy = devm_kzalloc(&client->dev, sizeof(struct nxp_nci_i2c_phy),
 			   GFP_KERNEL);
-	if (!phy) {
-		r = -ENOMEM;
-		goto probe_exit;
-	}
+	if (!phy)
+		return -ENOMEM;
 
 	phy->i2c_dev = client;
 	i2c_set_clientdata(client, phy);
@@ -298,7 +295,7 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
 	r = nxp_nci_probe(phy, &client->dev, &i2c_phy_ops,
 			  NXP_NCI_I2C_MAX_PAYLOAD, &phy->ndev);
 	if (r < 0)
-		goto probe_exit;
+		return r;
 
 	r = request_threaded_irq(client->irq, NULL,
 				 nxp_nci_i2c_irq_thread_fn,
@@ -307,7 +304,6 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
 	if (r < 0)
 		nfc_err(&client->dev, "Unable to register IRQ handler\n");
 
-probe_exit:
 	return r;
 }
 
Signature · 1 line
2.20.1
#17 lore raw

PATCH v3 14/14 NFC: nxp-nci: Fix recommendation for NFC_NXP_NCI_I2C Kconfig

In reply to Andy Shevchenko

From: Sedat Dilek <[email protected]>

This is a simple cleanup to the Kconfig help text as discussed in [1].

[1] https://marc.info/?t=155774435600001&r=1&w=2

---
 drivers/nfc/nxp-nci/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/nxp-nci/Kconfig +1 -1
index 746b91aa74f0..e1f71deab6fc 100644
@@ -22,4 +22,4 @@ config NFC_NXP_NCI_I2C
 
 	  To compile this driver as a module, choose m here. The module will
 	  be called nxp_nci_i2c.
-	  Say Y if unsure.
+	  Say N if unsure.
Signature · 1 line
2.20.1
#8 lore raw

PATCH v3 9/14 NFC: nxp-nci: Drop of_match_ptr() use

In reply to Andy Shevchenko

There is no need to guard OF device ID table with of_match_ptr(). Otherwise we would get a defined but not used data.

---
 drivers/nfc/nxp-nci/i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/nxp-nci/i2c.c +1 -1
index 4e71962dc557..f2c8a560e265 100644
@@ -342,7 +342,7 @@ static struct i2c_driver nxp_nci_i2c_driver = {
 	.driver = {
 		   .name = NXP_NCI_I2C_DRIVER_NAME,
 		   .acpi_match_table = ACPI_PTR(acpi_id),
-		   .of_match_table = of_match_ptr(of_nxp_nci_i2c_match),
+		   .of_match_table = of_nxp_nci_i2c_match,
 		  },
 	.probe = nxp_nci_i2c_probe,
 	.id_table = nxp_nci_i2c_id_table,
Signature · 1 line
2.20.1
#9 lore raw

PATCH v3 10/14 NFC: nxp-nci: Drop comma in terminator lines

In reply to Andy Shevchenko

There is no need to have a comma after terminator entry in the arrays of IDs.

This may prevent the misguided addition behind the terminator without compiler notice.

Drop the comma in terminator lines for good.

---
 drivers/nfc/nxp-nci/i2c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nfc/nxp-nci/i2c.c +2 -2
index f2c8a560e265..59b0a02a813d 100644
@@ -325,7 +325,7 @@ MODULE_DEVICE_TABLE(i2c, nxp_nci_i2c_id_table);
 
 static const struct of_device_id of_nxp_nci_i2c_match[] = {
 	{ .compatible = "nxp,nxp-nci-i2c", },
-	{},
+	{}
 };
 MODULE_DEVICE_TABLE(of, of_nxp_nci_i2c_match);
 
@@ -333,7 +333,7 @@ MODULE_DEVICE_TABLE(of, of_nxp_nci_i2c_match);
 static const struct acpi_device_id acpi_id[] = {
 	{ "NXP1001" },
 	{ "NXP7471" },
-	{ },
+	{ }
 };
 MODULE_DEVICE_TABLE(acpi, acpi_id);
 #endif
Signature · 1 line
2.20.1
#10 lore raw

PATCH v3 11/14 NFC: nxp-nci: Remove unused macro pr_fmt()

In reply to Andy Shevchenko

The macro had never been used.

---
 drivers/nfc/nxp-nci/i2c.c | 2 --
 1 file changed, 2 deletions(-)
drivers/nfc/nxp-nci/i2c.c +0 -2
index 59b0a02a813d..307bd2afbe05 100644
@@ -12,8 +12,6 @@
  * Copyright (C) 2012  Intel Corporation. All rights reserved.
  */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
 #include <linux/acpi.h>
 #include <linux/delay.h>
 #include <linux/i2c.h>
Signature · 1 line
2.20.1
#16 lore raw

PATCH v3 13/14 NFC: nxp-nci: Clarify on supported chips

In reply to Andy Shevchenko

From: Sedat Dilek <[email protected]>

This patch clarifies on the supported NXP NCI chips and families and lists PN547 and PN548 separately which are known as NPC100 respectively NPC300.

This helps to find informations and identify drivers on vendor's support websites.

For details see the discussion in [1] and [2].

[1] https://marc.info/?t=155774435600001&r=1&w=2
[2] https://patchwork.kernel.org/project/linux-wireless/list/?submitter=33142

---
 drivers/nfc/nxp-nci/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nfc/nxp-nci/Kconfig +2 -2
index ed6cbdf0f0b4..746b91aa74f0 100644
@@ -3,8 +3,8 @@ config NFC_NXP_NCI
 	tristate "NXP-NCI NFC driver"
 	depends on NFC_NCI
 	---help---
-	  Generic core driver for NXP NCI chips such as the NPC100
-	  or PN7150 families.
+	  Generic core driver for NXP NCI chips such as the NPC100 (PN547),
+	  NPC300 (PN548) or PN7150 families.
 	  This is a driver based on the NCI NFC kernel layers and
 	  will thus not work with NXP libnfc library.
 
Signature · 1 line
2.20.1
#15 lore raw

PATCH v3 12/14 NFC: nxp-nci: Remove 'default n' for the core

In reply to Andy Shevchenko

It seems contributors follow the style of Kconfig entries where explicit 'default n' is present. The default 'default' is 'n' already, thus, drop these lines from Kconfig to make it more clear.

---
 drivers/nfc/nxp-nci/Kconfig | 1 -
 1 file changed, 1 deletion(-)
drivers/nfc/nxp-nci/Kconfig +0 -1
index 12df2c8cc51d..ed6cbdf0f0b4 100644
@@ -2,7 +2,6 @@
 config NFC_NXP_NCI
 	tristate "NXP-NCI NFC driver"
 	depends on NFC_NCI
-	default n
 	---help---
 	  Generic core driver for NXP NCI chips such as the NPC100
 	  or PN7150 families.
Signature · 1 line
2.20.1
#2 lore raw

PATCH v3 3/14 NFC: nxp-nci: Get rid of platform data

In reply to Andy Shevchenko

Legacy platform data must go away. We are on the safe side here since there are no users of it in the kernel.

If anyone by any odd reason needs it the GPIO lookup tables and built-in device properties at your service.

---
 MAINTAINERS                           |  1 -
 drivers/nfc/nxp-nci/core.c            |  1 -
 drivers/nfc/nxp-nci/i2c.c             |  9 +--------
 drivers/nfc/nxp-nci/nxp-nci.h         |  1 -
 include/linux/platform_data/nxp-nci.h | 19 -------------------
 5 files changed, 1 insertion(+), 30 deletions(-)
 delete mode 100644 include/linux/platform_data/nxp-nci.h
MAINTAINERS +0 -1
index 711b5d07f73d..e54e19f2c96d 100644
@@ -11351,7 +11351,6 @@ F:	include/net/nfc/
 F:	include/uapi/linux/nfc.h
 F:	drivers/nfc/
 F:	include/linux/platform_data/nfcmrvl.h
-F:	include/linux/platform_data/nxp-nci.h
 F:	Documentation/devicetree/bindings/net/nfc/
 
 NFS, SUNRPC, AND LOCKD CLIENTS
drivers/nfc/nxp-nci/core.c +0 -1
index 8dafc696719f..aed18ca60170 100644
@@ -14,7 +14,6 @@
 #include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/nfc.h>
-#include <linux/platform_data/nxp-nci.h>
 
 #include <net/nfc/nci_core.h>
 
drivers/nfc/nxp-nci/i2c.c +1 -8
index 5db71869f04b..47b3b7e612e6 100644
@@ -23,7 +23,6 @@
 #include <linux/gpio/consumer.h>
 #include <linux/of_gpio.h>
 #include <linux/of_irq.h>
-#include <linux/platform_data/nxp-nci.h>
 #include <asm/unaligned.h>
 
 #include <net/nfc/nfc.h>
@@ -304,7 +303,6 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
 			    const struct i2c_device_id *id)
 {
 	struct nxp_nci_i2c_phy *phy;
-	struct nxp_nci_nfc_platform_data *pdata;
 	int r;
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
@@ -323,17 +321,12 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
 	phy->i2c_dev = client;
 	i2c_set_clientdata(client, phy);
 
-	pdata = client->dev.platform_data;
-
-	if (!pdata && client->dev.of_node) {
+	if (client->dev.of_node) {
 		r = nxp_nci_i2c_parse_devtree(client);
 		if (r < 0) {
 			nfc_err(&client->dev, "Failed to get DT data\n");
 			goto probe_exit;
 		}
-	} else if (pdata) {
-		phy->gpio_en = pdata->gpio_en;
-		phy->gpio_fw = pdata->gpio_fw;
 	} else if (ACPI_HANDLE(&client->dev)) {
 		r = nxp_nci_i2c_acpi_config(phy);
 		if (r < 0)
drivers/nfc/nxp-nci/nxp-nci.h +0 -1
index 6fe7c45544bf..ae3fb2735a4e 100644
@@ -14,7 +14,6 @@
 #include <linux/completion.h>
 #include <linux/firmware.h>
 #include <linux/nfc.h>
-#include <linux/platform_data/nxp-nci.h>
 
 #include <net/nfc/nci_core.h>
 
include/linux/platform_data/nxp-nci.h deleted +0 -19
deleted file mode 100644
index 97827ad468e2..000000000000
@@ -1,19 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Generic platform data for the NXP NCI NFC chips.
- *
- * Copyright (C) 2014  NXP Semiconductors  All rights reserved.
- *
- * Authors: Clément Perrochaud <[email protected]>
- */
-
-#ifndef _NXP_NCI_H_
-#define _NXP_NCI_H_
-
-struct nxp_nci_nfc_platform_data {
-	unsigned int gpio_en;
-	unsigned int gpio_fw;
-	unsigned int irq;
-};
-
-#endif /* _NXP_NCI_H_ */
Signature · 1 line
2.20.1
#4 lore raw

PATCH v3 5/14 NFC: nxp-nci: Add GPIO ACPI mapping table

In reply to Andy Shevchenko

In order to unify GPIO resource request prepare gpiod_get_index() to behave correctly when there is no mapping provided by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and their names used in the driver.

---
 drivers/nfc/nxp-nci/i2c.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/nfc/nxp-nci/i2c.c +16 -2
index 713c267acf88..7344405feddf 100644
@@ -247,6 +247,15 @@ static irqreturn_t nxp_nci_i2c_irq_thread_fn(int irq, void *phy_id)
 	return IRQ_NONE;
 }
 
+static const struct acpi_gpio_params firmware_gpios = { 1, 0, false };
+static const struct acpi_gpio_params enable_gpios = { 2, 0, false };
+
+static const struct acpi_gpio_mapping acpi_nxp_nci_gpios[] = {
+	{ "enable-gpios", &enable_gpios, 1 },
+	{ "firmware-gpios", &firmware_gpios, 1 },
+	{ }
+};
+
 static int nxp_nci_i2c_parse_devtree(struct i2c_client *client)
 {
 	struct nxp_nci_i2c_phy *phy = i2c_get_clientdata(client);
@@ -269,9 +278,14 @@ static int nxp_nci_i2c_parse_devtree(struct i2c_client *client)
 static int nxp_nci_i2c_acpi_config(struct nxp_nci_i2c_phy *phy)
 {
 	struct i2c_client *client = phy->i2c_dev;
+	int r;
 
-	phy->gpiod_en = devm_gpiod_get_index(&client->dev, NULL, 2, GPIOD_OUT_LOW);
-	phy->gpiod_fw = devm_gpiod_get_index(&client->dev, NULL, 1, GPIOD_OUT_LOW);
+	r = devm_acpi_dev_add_driver_gpios(&client->dev, acpi_nxp_nci_gpios);
+	if (r)
+		return r;
+
+	phy->gpiod_en = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
+	phy->gpiod_fw = devm_gpiod_get(&client->dev, "firmware", GPIOD_OUT_LOW);
 
 	if (IS_ERR(phy->gpiod_en) || IS_ERR(phy->gpiod_fw)) {
 		nfc_err(&client->dev, "No GPIOs\n");
Signature · 1 line
2.20.1
#18 lore raw
In reply to Andy Shevchenko

[ Please CC me I am not subscribed to this ML ]

Hi Andy,

unfortunately, I did not found a cover-letter on netdev mailing-list. So, I am answering here.

What are the changes v2->v3?

Again, unfortunately I throw away all v2 out of my local linux Git repository. So, I could have looked at the diff myself.

Thanks for v3 upgrade!

Regards,
- Sedat -

[1] https://marc.info/?a=131071969100005&r=1&w=2

Quoted 46 lines

Andy Shevchenko <[email protected]> hat am 25. Juli 2019 21:34 geschrieben:

From: Andrey Konovalov <[email protected]>

nfc_genl_deactivate_target() relies on the NFC_ATTR_TARGET_INDEX attribute being present, but doesn't check whether it is actually provided by the user. Same goes for nfc_genl_fw_download() and NFC_ATTR_FIRMWARE_NAME.

This patch adds appropriate checks.

Found with syzkaller.

---
 net/nfc/netlink.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/nfc/netlink.c +4 -2
index 4a30309bb67f..60fd2748d0ea 100644
@@ -970,7 +970,8 @@ static int nfc_genl_dep_link_down(struct sk_buff *skb, struct genl_info *info)
 	int rc;
 	u32 idx;
 
-	if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
+	if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
+	    !info->attrs[NFC_ATTR_TARGET_INDEX])
 		return -EINVAL;
 
 	idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
@@ -1018,7 +1019,8 @@ static int nfc_genl_llc_get_params(struct sk_buff *skb, struct genl_info *info)
 	struct sk_buff *msg = NULL;
 	u32 idx;
 
-	if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
+	if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
+	    !info->attrs[NFC_ATTR_FIRMWARE_NAME])
 		return -EINVAL;
 
 	idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
Signature · 1 line
2.20.1
Signature · 14 lines
Mit freundlichen Grüssen 
Sedat Dilek
Telefon: +49 2166 9901-153 
E-Mail: [email protected] 
Internet: https://www.credativ.de/

GPG-Fingerprint: EA6D E17D D269 AC7E 101D C910 476F 2B3B 0AF7 F86B

credativ GmbH, Trompeterallee 108, 41189 Mönchengladbach 
Handelsregister: Amtsgericht Mönchengladbach HRB 12080 USt-ID-Nummer DE204566209 
Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer

Unser Umgang mit personenbezogenen Daten unterliegt folgenden Bestimmungen: 
https://www.credativ.de/datenschutz/
#19 lore raw
Quoted 8 lines · Sedat Dilek

[ Please CC me I am not subscribed to this ML ]

Hi Andy,

unfortunately, I did not found a cover-letter on netdev mailing-list. So, I am answering here.

What are the changes v2->v3?

I combined my 11 patches with 1 from syzkaller team and 2 from you. That's only the change for the series.

Administratively I resent it to have updated Cc list.

Quoted 2 lines

Again, unfortunately I throw away all v2 out of my local linux Git repository. So, I could have looked at the diff myself.

It should be no changes in the code.

Quoted 71 lines

Thanks for v3 upgrade!

Regards,
- Sedat -

[1] https://marc.info/?a=131071969100005&r=1&w=2

Quoted 46 lines

Andy Shevchenko <[email protected]> hat am 25. Juli 2019 21:34 geschrieben:

From: Andrey Konovalov <[email protected]>

nfc_genl_deactivate_target() relies on the NFC_ATTR_TARGET_INDEX attribute being present, but doesn't check whether it is actually provided by the user. Same goes for nfc_genl_fw_download() and NFC_ATTR_FIRMWARE_NAME.

This patch adds appropriate checks.

Found with syzkaller.

---
 net/nfc/netlink.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/nfc/netlink.c +4 -2
index 4a30309bb67f..60fd2748d0ea 100644
@@ -970,7 +970,8 @@ static int nfc_genl_dep_link_down(struct sk_buff *skb, struct genl_info *info)
 	int rc;
 	u32 idx;
 
-	if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
+	if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
+	    !info->attrs[NFC_ATTR_TARGET_INDEX])
 		return -EINVAL;
 
 	idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
@@ -1018,7 +1019,8 @@ static int nfc_genl_llc_get_params(struct sk_buff *skb, struct genl_info *info)
 	struct sk_buff *msg = NULL;
 	u32 idx;
 
-	if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
+	if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
+	    !info->attrs[NFC_ATTR_FIRMWARE_NAME])
 		return -EINVAL;
 
 	idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
Signature · 1 line
2.20.1
Signature · 14 lines
Mit freundlichen Grüssen 
Sedat Dilek
Telefon: +49 2166 9901-153 
E-Mail: [email protected] 
Internet: https://www.credativ.de/

GPG-Fingerprint: EA6D E17D D269 AC7E 101D C910 476F 2B3B 0AF7 F86B

credativ GmbH, Trompeterallee 108, 41189 Mönchengladbach 
Handelsregister: Amtsgericht Mönchengladbach HRB 12080 USt-ID-Nummer DE204566209 
Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer

Unser Umgang mit personenbezogenen Daten unterliegt folgenden Bestimmungen: 
https://www.credativ.de/datenschutz/
Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#11 lore raw

Re: [PATCH v3 11/14] NFC: nxp-nci: Remove unused macro pr_fmt()

In reply to Andy Shevchenko

From: Andy Shevchenko <[email protected]>
Date: Thu, 25 Jul 2019 22:35:08 +0300

Quoted 4 lines

The macro had never been used.

...

drivers/nfc/nxp-nci/i2c.c line 15

Quoted 5 lines
drivers/nfc/nxp-nci/i2c.c +0 -1
@@ -12,8 +12,6 @@
  * Copyright (C) 2012  Intel Corporation. All rights reserved.
  */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

If there are any kernel log messages generated, which is the case in this file, this is used.

Also, please resubmit this series with a proper header posting containing a high level description of what this patch series does, how it is doing it, and why it is doing it that way. Also include a changelog.

Thank you.

#12 lore raw

Re: [PATCH v3 11/14] NFC: nxp-nci: Remove unused macro pr_fmt()

Quoted 8 lines · David Miller

From: Andy Shevchenko <[email protected]>
Date: Thu, 25 Jul 2019 22:35:08 +0300

Quoted 4 lines

The macro had never been used.

...

Quoted 8 lines

drivers/nfc/nxp-nci/i2c.c line 15

Quoted 5 lines
drivers/nfc/nxp-nci/i2c.c +0 -1
@@ -12,8 +12,6 @@
  * Copyright (C) 2012  Intel Corporation. All rights reserved.
  */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

If there are any kernel log messages generated, which is the case in this file, this is used.

AFAICS no, it's not.
All nfc_*() macros are built on top of dev_*() ones for which pr_fmt() is no-op. If we would like to have it in that way, we rather should use dev_fmt().

Quoted 3 lines

Also, please resubmit this series with a proper header posting containing a high level description of what this patch series does, how it is doing it, and why it is doing it that way. Also include a changelog.

Will do.

Thank you for review!

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#13 lore raw

Re: [PATCH v3 11/14] NFC: nxp-nci: Remove unused macro pr_fmt()

Quoted 24 lines · Andy Shevchenko
Quoted 8 lines · David Miller

From: Andy Shevchenko <[email protected]>
Date: Thu, 25 Jul 2019 22:35:08 +0300

Quoted 4 lines

The macro had never been used.

...

Quoted 8 lines

drivers/nfc/nxp-nci/i2c.c line 15

Quoted 5 lines
drivers/nfc/nxp-nci/i2c.c +0 -1
@@ -12,8 +12,6 @@
  * Copyright (C) 2012  Intel Corporation. All rights reserved.
  */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

If there are any kernel log messages generated, which is the case in this file, this is used.

AFAICS no, it's not.
All nfc_*() macros are built on top of dev_*() ones for which pr_fmt() is no-op. If we would like to have it in that way, we rather should use dev_fmt().

Quoted 8 lines
Quoted 3 lines

Also, please resubmit this series with a proper header posting containing a high level description of what this patch series does, how it is doing it, and why it is doing it that way. Also include a changelog.

Will do.

Thank you for review!

Can you send out the latest series as v5?
I got some new? patches from you, but a bit confused now.

- Sedat -

#14 lore raw

Re: [PATCH v3 11/14] NFC: nxp-nci: Remove unused macro pr_fmt()

Quoted 31 lines · Sedat Dilek
Quoted 28 lines · Andy Shevchenko
Quoted 8 lines · David Miller

From: Andy Shevchenko <[email protected]>
Date: Thu, 25 Jul 2019 22:35:08 +0300

Quoted 4 lines

The macro had never been used.

...

Quoted 8 lines

drivers/nfc/nxp-nci/i2c.c line 15

Quoted 5 lines
drivers/nfc/nxp-nci/i2c.c +0 -1
@@ -12,8 +12,6 @@
  * Copyright (C) 2012  Intel Corporation. All rights reserved.
  */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

If there are any kernel log messages generated, which is the case in this file, this is used.

AFAICS no, it's not.
All nfc_*() macros are built on top of dev_*() ones for which pr_fmt() is no-op. If we would like to have it in that way, we rather should use dev_fmt().

Quoted 3 lines

Also, please resubmit this series with a proper header posting containing a high level description of what this patch series does, how it is doing it, and why it is doing it that way. Also include a changelog.

Quoted 8 lines
Quoted 4 lines

Will do.

Thank you for review!

Can you send out the latest series as v5?
I got some new? patches from you, but a bit confused now.

Thanks for the cover-letter.

- Sedat -

[1] https://marc.info/?l=linux-netdev&m=156440732411578&w=2