[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANE+tVrFOev4GjjbM1=P4gPHJEqLvbMHJfYfVH_L6NVVDnu0DA@mail.gmail.com>
Date: Mon, 27 Feb 2023 09:26:45 +0800
From: Kang Chen <void0red@...il.com>
To: Simon Horman <simon.horman@...igine.com>
Cc: krzysztof.kozlowski@...aro.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] nfc: fdp: add null check of devm_kmalloc_array in fdp_nci_i2c_read_device_properties
Hi Simon,
I will update the patch later.
Thank you for your review.
On Sun, Feb 26, 2023 at 11:33 PM Simon Horman <simon.horman@...igine.com> wrote:
>
> 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@...il.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
> >
Powered by blists - more mailing lists