From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Ajay Kumar <ajaykumar.rs@samsung.com>
Cc: mark.rutland@arm.com, shaik.ameer@samsung.com,
robin.murphy@arm.com, nleeder@codeaurora.org,
shameerali.kolothum.thodi@huawei.com, robh+dt@kernel.org,
alim.akhtar@samsung.com, will@kernel.org, joro@8bytes.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 4/4] perf/smmuv3: fix crash when platdata not specified
Date: Mon, 13 Jul 2020 09:46:25 +0100 [thread overview]
Message-ID: <20200713094625.00002bb7@Huawei.com> (raw)
In-Reply-To: <20200712163341.61410-5-ajaykumar.rs@samsung.com>
On Sun, 12 Jul 2020 22:03:41 +0530
Ajay Kumar <ajaykumar.rs@samsung.com> wrote:
> The arm_smmuv3_pmu driver assumes platform data is always
> available and exposes a possible NULL pointer deferencing
> at the below line.
>
> model = *(u32 *)dev_get_platdata(smmu_pmu->dev);
>
> This patch fixes the bug by adding a check prior to the
> deferencing of the platform data pointer.
>
> Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
> ---
> drivers/perf/arm_smmuv3_pmu.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c
> index 25feab718c20..f7a27ae2f8d8 100644
> --- a/drivers/perf/arm_smmuv3_pmu.c
> +++ b/drivers/perf/arm_smmuv3_pmu.c
> @@ -710,9 +710,10 @@ static void smmu_pmu_reset(struct smmu_pmu *smmu_pmu)
>
> static void smmu_pmu_get_acpi_options(struct smmu_pmu *smmu_pmu)
> {
> - u32 model;
> + u32 model = 0;
Use the generic model define. Sure it's 0, but good to make it clear what
the meaning of this default is.
It also seems likely you hit this because of you were using dt.
If so, it seems 'odd' to be running a function explicitly mentioning acpi in
it's name.
Also, should do this before introducing support that might lead to this path
so as not to cause bisection problems.
Jonathan
>
> - model = *(u32 *)dev_get_platdata(smmu_pmu->dev);
> + if (dev_get_platdata(smmu_pmu->dev))
> + model = *(u32 *)dev_get_platdata(smmu_pmu->dev);
>
> switch (model) {
> case IORT_SMMU_V3_PMCG_HISI_HIP08:
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-07-13 8:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20200712165509epcas5p29e66777a4e0115420b9104ba5aa83f57@epcas5p2.samsung.com>
2020-07-12 16:33 ` [PATCH 0/4] Add DT support for arm_smmuv3_pmu driver Ajay Kumar
2020-07-12 16:33 ` [PATCH 1/4] perf/smmuv3: Remove dependency on CONFIG_ACPI Ajay Kumar
2020-07-12 16:33 ` [PATCH 2/4] Documentation: perf: Add documentation for arm-smmu-v3-pmcg Ajay Kumar
2020-07-13 8:41 ` Jonathan Cameron
2020-07-12 16:33 ` [PATCH 3/4] perf/smmuv3: add device tree support Ajay Kumar
2020-07-12 16:33 ` [PATCH 4/4] perf/smmuv3: fix crash when platdata not specified Ajay Kumar
2020-07-13 8:46 ` Jonathan Cameron [this message]
2020-07-13 9:46 ` Robin Murphy
2020-07-13 9:42 ` [PATCH 0/4] Add DT support for arm_smmuv3_pmu driver Robin Murphy
2020-07-13 9:57 ` John Garry
2020-07-13 10:17 ` Ajay kumar
2020-07-13 10:28 ` Robin Murphy
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=20200713094625.00002bb7@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=ajaykumar.rs@samsung.com \
--cc=alim.akhtar@samsung.com \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=nleeder@codeaurora.org \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--cc=shaik.ameer@samsung.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=will@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).