From: Sylwester Nawrocki <snawrocki@kernel.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>,
Ben Dooks <ben-linux@fluff.org>,
Jaehoon Chung <jh80.chung@samsung.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH 1/3] mmc: sdhci-s3c: fix possible NULL pointer dereference when probed via platform
Date: Wed, 14 Apr 2021 18:49:41 +0200 [thread overview]
Message-ID: <74059494-3610-c24e-7d09-b89106c0a396@kernel.org> (raw)
In-Reply-To: <a0ac5d21-acc1-825a-1585-f8d897902b14@canonical.com>
On 14.04.2021 17:25, Krzysztof Kozlowski wrote:
> On 14/04/2021 17:12, Krzysztof Kozlowski wrote:
>> The driver can be matched by legacy platform way or OF-device matching.
>> In the first case, of_match_node() can return NULL, which immediately
>> would be dereferenced to get the match data.
>>
>> Addresses-Coverity: Dereference null return value
>> Fixes: cd1b00eb24b0 ("mmc: sdhci-s3c: Add device tree support")
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
>> -#ifdef CONFIG_OF
>> -static const struct of_device_id sdhci_s3c_dt_match[];
>> -#endif
>> -
>> static inline struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
>> struct platform_device *pdev)
>> {
>> #ifdef CONFIG_OF
>> - if (pdev->dev.of_node) {
>> - const struct of_device_id *match;
>> - match = of_match_node(sdhci_s3c_dt_match, pdev->dev.of_node);
>
> Now I have second thoughts whether NULL pointer can actually happen. If
> device is matched via platform/board files, maybe the pdev->dev.of_node
> will be NULL thus skipping this branch?
>
> Could there be a case where device is matched via platform_device_id()
> (which has different name than compatible!) and (pdev->dev.of_node) is
> still assigned? Maybe in case of out of tree DTS?
That seems unlikely, the platform device would need to be initialized
via board file and then its of_node assigned somehow. It doesn't make
much sense to me. We either use board file or dtb to instantiate devices.
> Anyway, the patch makes the code simpler/smaller, so I still think it is
> reasonable. Just the severity of issue is questionable...
Yes, the patch looks good. Similar cleanups are already done in most of
the s3c/s5p/exynos drivers.
--
Thanks,
Sylwester
next prev parent reply other threads:[~2021-04-14 16:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-14 15:12 Krzysztof Kozlowski
2021-04-14 15:12 ` [PATCH 2/3] mmc: sdhci-s3c: correct kerneldoc of sdhci_s3c_drv_data Krzysztof Kozlowski
2021-04-14 15:12 ` [PATCH 3/3] mmc: sdhci-s3c: constify uses of driver/match data Krzysztof Kozlowski
2021-04-14 15:25 ` [PATCH 1/3] mmc: sdhci-s3c: fix possible NULL pointer dereference when probed via platform Krzysztof Kozlowski
2021-04-14 16:49 ` Sylwester Nawrocki [this message]
2021-04-15 8:41 ` Krzysztof Kozlowski
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=74059494-3610-c24e-7d09-b89106c0a396@kernel.org \
--to=snawrocki@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ben-linux@fluff.org \
--cc=jh80.chung@samsung.com \
--cc=krzysztof.kozlowski@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=ulf.hansson@linaro.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
all inboxes | Powered by JetHome®