lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJX_Q+21M+W6B2Ab9TZeNSSCVdLcU1J1LBCHO13CR0T+e=SVOQ@mail.gmail.com>
Date:   Mon, 5 Aug 2019 14:43:53 +0100
From:   Lucas Tanure <tanure@...ux.com>
To:     linux-kernel@...r.kernel.org
Subject: Question about mfd_add_devices and platform_data

Hi,

I would like to understand mfd_add_devices call and platform_data section.
An mfd device can have platform_data, which is kmemdup at
platform_device_add_data from platform_device_add_data call inside
mfd_add_device. And after this kmemdup the new mfd device receives the
clone memory and the pointer given to platform_device_add_data is freed.

All the drivers I read the platform_data is static, which in my view can
not be freed and kfrees says:

"Don't free memory not originally allocated by kmalloc() or you will run
into trouble."

So, my questions is : Should my driver kmalloc platform_data first and then
call mfd_add_devices ? Or it's fine to give static memory to it ?

Example driver:

drivers/mfd/vexpress-sysreg.c:

static struct syscon_platform_data vexpress_sysreg_sys_id_pdata = {
.label = "sys_id",
};

static struct mfd_cell vexpress_sysreg_cells[] = {
{
.name = "syscon",
.num_resources = 1,
.resources = (struct resource []) {
DEFINE_RES_MEM(SYS_ID, 0x4),
},
.platform_data = &vexpress_sysreg_sys_id_pdata,
.pdata_size = sizeof(vexpress_sysreg_sys_id_pdata),
},

For this case mfd_add_devices will free vexpress_sysreg_sys_id_pdata, but
it's static.

Thanks
Lucas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ