drivers/nfc/fdp/i2c.c | 4 ++++ 1 file changed, 4 insertions(+)
From: Kang Chen <void0red@gmail.com>
devm_kmalloc_array may fails, *fw_vsc_cfg might be null and cause
out-of-bounds write in device_property_read_u8_array later.
Fixes: a06347c04c13 ("NFC: Add Intel Fields Peak NFC solution driver")
Signed-off-by: Kang Chen <void0red@gmail.com>
---
v3 -> v2: remove useless prompt and blank lines between tags.
v2 -> v1: add debug prompt and Fixes tag
drivers/nfc/fdp/i2c.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
index 2d53e0f88..1e0f2297f 100644
--- a/drivers/nfc/fdp/i2c.c
+++ b/drivers/nfc/fdp/i2c.c
@@ -247,6 +247,9 @@ static void fdp_nci_i2c_read_device_properties(struct device *dev,
len, sizeof(**fw_vsc_cfg),
GFP_KERNEL);
+ if (!*fw_vsc_cfg)
+ goto alloc_err;
+
r = device_property_read_u8_array(dev, FDP_DP_FW_VSC_CFG_NAME,
*fw_vsc_cfg, len);
@@ -260,6 +263,7 @@ static void fdp_nci_i2c_read_device_properties(struct device *dev,
*fw_vsc_cfg = NULL;
}
+alloc_err:
dev_dbg(dev, "Clock type: %d, clock frequency: %d, VSC: %s",
*clock_type, *clock_freq, *fw_vsc_cfg != NULL ? "yes" : "no");
}
--
2.34.1
Hello: This patch was applied to netdev/net.git (main) by Paolo Abeni <pabeni@redhat.com>: On Mon, 27 Feb 2023 17:30:37 +0800 you wrote: > From: Kang Chen <void0red@gmail.com> > > devm_kmalloc_array may fails, *fw_vsc_cfg might be null and cause > out-of-bounds write in device_property_read_u8_array later. > > Fixes: a06347c04c13 ("NFC: Add Intel Fields Peak NFC solution driver") > Signed-off-by: Kang Chen <void0red@gmail.com> > > [...] Here is the summary with links: - [v3] nfc: fdp: add null check of devm_kmalloc_array in fdp_nci_i2c_read_device_properties https://git.kernel.org/netdev/net/c/11f180a5d62a You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
On Mon, Feb 27, 2023 at 05:30:37PM +0800, void0red wrote: > [You don't often get email from void0red@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] > > From: Kang Chen <void0red@gmail.com> > > devm_kmalloc_array may fails, *fw_vsc_cfg might be null and cause > out-of-bounds write in device_property_read_u8_array later. > > Fixes: a06347c04c13 ("NFC: Add Intel Fields Peak NFC solution driver") > Signed-off-by: Kang Chen <void0red@gmail.com> Reviewed-by: Simon Horman <simon.horman@corigine.com>
On 27/02/2023 10:30, void0red wrote: > From: Kang Chen <void0red@gmail.com> > > devm_kmalloc_array may fails, *fw_vsc_cfg might be null and cause > out-of-bounds write in device_property_read_u8_array later. > > Fixes: a06347c04c13 ("NFC: Add Intel Fields Peak NFC solution driver") > Signed-off-by: Kang Chen <void0red@gmail.com> > --- > v3 -> v2: remove useless prompt and blank lines between tags. Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Best regards, Krzysztof
© 2016 - 2025 Red Hat, Inc.