From: Viacheslav <adeep@lexina.in>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Kevin Hilman <khilman@baylibre.com>,
Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org
Cc: Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
Subject: Re: [PATCH v3 2/4] soc: amlogic: meson-gx-socinfo-sm: Add Amlogic secure-monitor SoC Information driver
Date: Thu, 14 Mar 2024 16:59:09 +0300 [thread overview]
Message-ID: <c0352b99-ca25-4357-bc26-470d802dbf71@lexina.in> (raw)
In-Reply-To: <df615536-8034-464a-8dba-c890b70edc1f@linaro.org>
14/03/2024 16.31, Krzysztof Kozlowski wrote:
> On 14/03/2024 13:22, Viacheslav wrote:
>>> +
>>>> + soc_dev_attr = devm_kzalloc(&pdev->dev, sizeof(*soc_dev_attr),
>>>> + GFP_KERNEL);
>>>> + if (!soc_dev_attr)
>>>> + return -ENOMEM;
>>>> +
>>>> + soc_dev_attr->serial_number = socinfo_get_chipid(&pdev->dev, fw, &socinfo);
>>>> +
>>>> + soc_dev_attr->family = "Amlogic Meson";
>>>> + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%x:%x - %x:%x",
>>>> + socinfo.v1.major_id,
>>>> + socinfo.v1.chip_rev,
>>>> + socinfo.v1.pack_id,
>>>> + (socinfo.v1.reserved<<4) + socinfo.v1.layout_ver);
>>>> + soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%s (%s)",
>>>> + socinfo_v1_to_soc_id(socinfo),
>>>> + socinfo_v1_to_package_id(socinfo));
>>>> +
>>>> + soc_dev = soc_device_register(soc_dev_attr);
>>>> +
>>>> +
>>>> + if (IS_ERR(soc_dev)) {
>>>> + kfree(soc_dev_attr->revision);
>>>> + kfree_const(soc_dev_attr->soc_id);
>>>> + kfree(soc_dev_attr);
>>>
>>> That's a double free. This was not tested.
>>
>>
>> Please, describe the problem.
>
> Test your code. What's the point of arguing over it if regular test
> would show this?
>
>> I don't quite understand what the issue is:
>>
>> - kfree() releases memory allocated with kmalloc()
>
> So point me where is kmalloc(). I don't see. I see only devm.
I missed the point that devm_kzalloc is automatically freed. You are
right. Thanks!
--
Best regards
Viacheslav
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2024-03-14 13:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-14 6:59 [PATCH v3 0/4] soc: amlogic: add new meson-gx-socinfo-sm driver Viacheslav Bocharov
2024-03-14 6:59 ` [PATCH v3 1/4] soc: amlogic: meson-gx-socinfo: move common code to header file Viacheslav Bocharov
2024-03-14 6:59 ` [PATCH v3 2/4] soc: amlogic: meson-gx-socinfo-sm: Add Amlogic secure-monitor SoC Information driver Viacheslav Bocharov
2024-03-14 7:11 ` Krzysztof Kozlowski
2024-03-14 12:22 ` Viacheslav
2024-03-14 13:31 ` Krzysztof Kozlowski
2024-03-14 13:59 ` Viacheslav [this message]
2024-03-14 6:59 ` [PATCH v3 3/4] soc: amlogic: meson-gx-socinfo: add new definition for Amlogic A113X package Viacheslav Bocharov
2024-03-14 6:59 ` [PATCH v3 4/4] arm64: dts: meson: add dts links to secure-monitor for soc driver in a1, axg, gx, g12 Viacheslav Bocharov
2024-03-14 10:40 ` [PATCH v3 0/4] soc: amlogic: add new meson-gx-socinfo-sm driver Sudeep Holla
2024-03-14 12:25 ` Viacheslav
2024-03-14 14:30 ` Sudeep Holla
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=c0352b99-ca25-4357-bc26-470d802dbf71@lexina.in \
--to=adeep@lexina.in \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=robh+dt@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
all inboxes | Powered by JetHome®