Re: [PATCH v3 18/18] media: atomisp: csi2-bridge: Add support for VCM I2C-client instantiation

Hans de Goede
2023-07-06T12:33:30Z

Hi,

On 7/6/23 12:15, Andy Shevchenko wrote:
> On Wed, Jul 05, 2023 at 11:30:10PM +0200, Hans de Goede wrote:
>> Fill sensor->vcm_type and call intel_cio2_bridge_instantiate_vcm() from
>> the v4l2-async bound op so that an I2C-client will be instatiated for
>> the VCM.
>>
>> Note unfortunately on atomisp the _DSM to get the VCM type sometimes
>> returns a VCM even though there is none. Since VCMs are typically only
>> used together with certain sensors, work around this by adding a vcm
>> field to atomisp_sensor_config and only check for a VCM when that is set.
>
> ...
>
>> +static char *atomisp_csi2_get_vcm_type(struct acpi_device *adev)
>> +{
>> + union acpi_object *obj;
>> + char *vcm_type;
>> +
>> + obj = acpi_evaluate_dsm_typed(adev->handle, &vcm_dsm_guid, 0, 0,
>> + NULL, ACPI_TYPE_STRING);
>> + if (!obj)
>> + return NULL;
>> +
>> + vcm_type = kstrdup(obj->string.pointer, GFP_KERNEL);
>
> Where is the counterpart kfree()?

The vcm-type is stored in one of the generated sw-nodes and the ipu-bridge
code only creates those once and them leaves them in memory, even on
a rmmod. So this is deliberately leaked just like that the ipu_bridge
struct which contains all the swnode-s is deliberately leaked by
ipu-bridge.c

Regards,

Hans

>
>> + ACPI_FREE(obj);
>> +
>> + if (!vcm_type)
>> + return NULL;
>> +
>> + string_lower(vcm_type, vcm_type);
>> + return vcm_type;
>> +}
>