[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231213171437.GI5817@kernel.org>
Date: Wed, 13 Dec 2023 17:14:37 +0000
From: Simon Horman <horms@...nel.org>
To: Przemek Kitszel <przemyslaw.kitszel@...el.com>
Cc: Kunwu Chan <chentao@...inos.cn>, jesse.brandeburg@...el.com,
anthony.l.nguyen@...el.com, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
richardcochran@...il.com, jacob.e.keller@...el.com,
karol.kolacinski@...el.com, michal.michalik@...el.com,
intel-wired-lan@...ts.osuosl.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Kunwu Chan <kunwu.chan@...mail.com>
Subject: Re: [PATCH v2 iwl-next] ice: Fix some null pointer dereference
issues in ice_ptp.c
On Wed, Dec 13, 2023 at 10:49:10AM +0100, Przemek Kitszel wrote:
> On 12/12/23 03:40, Kunwu Chan wrote:
> > devm_kasprintf() returns a pointer to dynamically allocated memory
> > which can be NULL upon failure.
> >
> > Fixes: d938a8cca88a ("ice: Auxbus devices & driver for E822 TS")
> > Cc: Kunwu Chan <kunwu.chan@...mail.com>
> > Suggested-by: Przemek Kitszel <przemyslaw.kitszel@...el.com>
>
> You found the bug (or some some static analysis tool in that case);
> there is no need to add Suggested-by for every person that suggests
> something during review - the tag is for "person/s that suggested
> making such change in the repo".
>
> Subject line would be better if less generic, eg:
> ice: avoid null deref of ptp auxbus name
>
> > Signed-off-by: Kunwu Chan <chentao@...inos.cn>
> > ---
> > drivers/net/ethernet/intel/ice/ice_ptp.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
> > index e9e59f4b5580..848e3e063e64 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> > @@ -2743,6 +2743,8 @@ static int ice_ptp_register_auxbus_driver(struct ice_pf *pf)
> > name = devm_kasprintf(dev, GFP_KERNEL, "ptp_aux_dev_%u_%u_clk%u",
> > pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn),
> > ice_get_ptp_src_clock_index(&pf->hw));
> > + if (!name)
> > + return -ENOMEM;
> > aux_driver->name = name;
> > aux_driver->shutdown = ice_ptp_auxbus_shutdown;
> > @@ -2989,6 +2991,8 @@ static int ice_ptp_create_auxbus_device(struct ice_pf *pf)
> > name = devm_kasprintf(dev, GFP_KERNEL, "ptp_aux_dev_%u_%u_clk%u",
> > pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn),
> > ice_get_ptp_src_clock_index(&pf->hw));
> > + if (!name)
> > + return -ENOMEM;
> > aux_dev->name = name;
> > aux_dev->id = id;
>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@...el.com>
>
> Regarding iwl-next vs iwl-net: this bug is really unlikely to manifest,
> as we take care of both earlier and future mem allocs for ptp auxbus,
> and auxiliary_device_init() checks for null name, so no big deal,
> so: -next is fine
Thanks. FWIIW, this looks good to me too.
Reviewed-by: Simon Horman <horms@...nel.org>
Powered by blists - more mailing lists