All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@corigine.com>
To: Kang Chen <void0red@gmail.com>
Cc: krzysztof.kozlowski@linaro.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nfc: fdp: add null check of devm_kmalloc_array in fdp_nci_i2c_read_device_properties
Date: Sun, 26 Feb 2023 16:33:47 +0100	[thread overview]
Message-ID: <Y/t729AIYjxuP6X6@corigine.com> (raw)
In-Reply-To: <20230226095933.3286710-1-void0red@gmail.com>

On Sun, Feb 26, 2023 at 05:59:33PM +0800, 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.
> 
> Signed-off-by: Kang Chen <void0red@gmail.com>

I'm not sure if this is a bug-fix (for stable).
But if so, I think the following is the appropriate fixes tag.

Fixes: a06347c04c13 ("NFC: Add Intel Fields Peak NFC solution driver")

> ---
>  drivers/nfc/fdp/i2c.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
> index 2d53e0f88..d95d20efa 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 vsc_read_err;

This leads to:

	dev_dbg(dev, "FW vendor specific commands not present\n");

Which seems a little misleading for this error condition.

> +
>  		r = device_property_read_u8_array(dev, FDP_DP_FW_VSC_CFG_NAME,
>  						  *fw_vsc_cfg, len);
>  
> -- 
> 2.34.1
> 

  reply	other threads:[~2023-02-26 15:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-26  9:59 [PATCH] nfc: fdp: add null check of devm_kmalloc_array in fdp_nci_i2c_read_device_properties Kang Chen
2023-02-26 15:33 ` Simon Horman [this message]
2023-02-27  1:26   ` Kang Chen
2023-02-27  1:41   ` [PATCH v2] " Kang Chen
2023-02-27  8:02     ` Krzysztof Kozlowski
2023-02-27  9:30       ` [PATCH v3] " void0red
2023-02-27  9:44         ` Krzysztof Kozlowski
2023-02-27 12:12         ` Simon Horman
2023-02-28 11:00         ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y/t729AIYjxuP6X6@corigine.com \
    --to=simon.horman@corigine.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=void0red@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.