From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Sai Krishna <saikrishnag@marvell.com>
Cc: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
<pabeni@redhat.com>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <sgoutham@marvell.com>,
<dan.carpenter@linaro.org>,
Naveen Mamindlapalli <naveenm@marvell.com>
Subject: Re: [net PATCH] octeontx2-af: Fix pointer dereference before sanity check
Date: Wed, 7 Jun 2023 13:46:41 +0200 [thread overview]
Message-ID: <ZIBuIXH2M1KbCg06@boxer> (raw)
In-Reply-To: <20230607070255.2013980-1-saikrishnag@marvell.com>
On Wed, Jun 07, 2023 at 12:32:55PM +0530, Sai Krishna wrote:
> PTP pointer is being dereferenced before NULL, error check.
> Fixed the same to avoid NULL dereference and smatch checker warning.
please use imperative mood, you could say:
Move validation of ptp pointer before its usage
>
> Fixes: 2ef4e45d99b1 ("octeontx2-af: Add PTP PPS Errata workaround on CN10K silicon")
> Signed-off-by: Sai Krishna <saikrishnag@marvell.com>
> Signed-off-by: Naveen Mamindlapalli <naveenm@marvell.com>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> drivers/net/ethernet/marvell/octeontx2/af/ptp.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/ptp.c b/drivers/net/ethernet/marvell/octeontx2/af/ptp.c
> index 3411e2e47d46..6a7dfb181fa8 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/ptp.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/ptp.c
> @@ -449,12 +449,12 @@ static void ptp_remove(struct pci_dev *pdev)
> struct ptp *ptp = pci_get_drvdata(pdev);
> u64 clock_cfg;
>
> - if (cn10k_ptp_errata(ptp) && hrtimer_active(&ptp->hrtimer))
> - hrtimer_cancel(&ptp->hrtimer);
> -
> if (IS_ERR_OR_NULL(ptp))
> return;
>
> + if (cn10k_ptp_errata(ptp) && hrtimer_active(&ptp->hrtimer))
> + hrtimer_cancel(&ptp->hrtimer);
> +
> /* Disable PTP clock */
> clock_cfg = readq(ptp->reg_base + PTP_CLOCK_CFG);
> clock_cfg &= ~PTP_CLOCK_CFG_PTP_EN;
i wonder if ptp_remove() would be able to free the struct ptp that
ptp_probe() allocated - then you wouldn't have to use devm_kzalloc().
> --
> 2.25.1
>
>
next prev parent reply other threads:[~2023-06-07 11:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 7:02 [net PATCH] octeontx2-af: Fix pointer dereference before sanity check Sai Krishna
2023-06-07 11:46 ` Maciej Fijalkowski [this message]
2023-06-07 12:04 ` Sai Krishna Gajula
2023-06-07 12:24 ` Maciej Fijalkowski
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=ZIBuIXH2M1KbCg06@boxer \
--to=maciej.fijalkowski@intel.com \
--cc=dan.carpenter@linaro.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=naveenm@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saikrishnag@marvell.com \
--cc=sgoutham@marvell.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