[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <35ddd789-4dd9-3b87-3128-268905ec9a13@linaro.org>
Date: Mon, 27 Feb 2023 09:02:27 +0100
From: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
To: Kang Chen <void0red@...il.com>, simon.horman@...igine.com
Cc: linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH v2] nfc: fdp: add null check of devm_kmalloc_array in
fdp_nci_i2c_read_device_properties
On 27/02/2023 02:41, Kang Chen wrote:
> 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")
>
No blank lines between tags.
> Signed-off-by: Kang Chen <void0red@...il.com>
> ---
> v2 -> v1: add debug prompt and Fixes tag
>
> drivers/nfc/fdp/i2c.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
> index 2d53e0f88..d3272a54b 100644
> --- a/drivers/nfc/fdp/i2c.c
> +++ b/drivers/nfc/fdp/i2c.c
> @@ -247,6 +247,11 @@ static void fdp_nci_i2c_read_device_properties(struct device *dev,
> len, sizeof(**fw_vsc_cfg),
> GFP_KERNEL);
>
> + if (!*fw_vsc_cfg) {
> + dev_dbg(dev, "Not enough memory\n");
No prints for memory allocation errors. Core prints it. Just go to
err_kmalloc.
> + goto out;
> + }
> +
> r = device_property_read_u8_array(dev, FDP_DP_FW_VSC_CFG_NAME,
> *fw_vsc_cfg, len);
>
> @@ -259,7 +264,7 @@ static void fdp_nci_i2c_read_device_properties(struct device *dev,
> dev_dbg(dev, "FW vendor specific commands not present\n");
> *fw_vsc_cfg = NULL;
> }
> -
Why? Line break seems nice here.
> +out:
> dev_dbg(dev, "Clock type: %d, clock frequency: %d, VSC: %s",
> *clock_type, *clock_freq, *fw_vsc_cfg != NULL ? "yes" : "no");
> }
Best regards,
Krzysztof
Powered by blists - more mailing lists