From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Kunwu Chan <chentao@kylinos.cn>, <jesse.brandeburg@intel.com>,
<anthony.l.nguyen@intel.com>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<richardcochran@gmail.com>, <jacob.e.keller@intel.com>,
<karol.kolacinski@intel.com>
Cc: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
linux-kernel@vger.kernel.org, michal.michalik@intel.com,
Kunwu Chan <kunwu.chan@hotmail.com>
Subject: Re: [Intel-wired-lan] [PATCH] ice: Fix some null pointer dereference issues in ice_ptp.c
Date: Mon, 11 Dec 2023 08:15:53 +0100 [thread overview]
Message-ID: <447d130a-e1ac-02f6-e168-b04bfa9c6004@intel.com> (raw)
In-Reply-To: <20231211062649.247148-1-chentao@kylinos.cn>
On 12/11/23 07:26, 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@hotmail.com>
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
I would suggest adding "iwl-net" as a target here
> ---
> drivers/net/ethernet/intel/ice/ice_ptp.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
> index 1eddcbe89b0c..59794ce4f243 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> @@ -2668,6 +2668,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;
> @@ -2929,6 +2931,10 @@ 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) {
> + dev_err(dev, "Failed to allocate memory\n");
Kuba @ [1]:
no warnings on allocation failures, there will be a splat for GFP_KERNEL
(checkpatch should catch this)
[1] https://lore.kernel.org/netdev/20231206195304.6226771d@kernel.org/T/
so just "return -ENOMEM" would be sufficient
> + return -ENOMEM;
> + }
>
> aux_dev->name = name;
> aux_dev->id = id;
I didn't checked but having same code in two places raises questions.
Are you overwriting old name here, or our code is just self similar?
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
next prev parent reply other threads:[~2023-12-11 7:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-11 6:26 [Intel-wired-lan] [PATCH] ice: Fix some null pointer dereference issues in ice_ptp.c Kunwu Chan
2023-12-11 7:15 ` Przemek Kitszel [this message]
2023-12-11 9:32 ` Kunwu Chan
2023-12-11 10:12 ` Przemek Kitszel
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=447d130a-e1ac-02f6-e168-b04bfa9c6004@intel.com \
--to=przemyslaw.kitszel@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=chentao@kylinos.cn \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jacob.e.keller@intel.com \
--cc=jesse.brandeburg@intel.com \
--cc=karol.kolacinski@intel.com \
--cc=kuba@kernel.org \
--cc=kunwu.chan@hotmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.michalik@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox