[libcamera-devel] [PATCH 1/2] libcamera: base: log: Fix use of freed name

Tomi Valkeinen tomi.valkeinen at ideasonboard.com
Sat Aug 27 09:23:14 CEST 2022


On 27/08/2022 04:28, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Fri, Aug 26, 2022 at 02:39:30PM +0300, Tomi Valkeinen via libcamera-devel wrote:
>> LogCategory just stores the char * that was given to it in the
>> constructor, i.e. it refers to memory "outside" LogCategory. If the
>> LogCategory is defined in a .so that is unloaded, then it leads to the
>> LogCategory pointing to freed memory, causing a crash.
>>
>> Fix this by taking a copy of the name by using a std::string instead of
>> just storing the pointer.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> 
> I won't apply this yet though, as it doesn't help much without 2/2, in
> case this patch needs to change in v2 due to changes in 2/2.

This does help alone, as it fixes a crash. The issues the second patch 
fixes are not fatal.

But no hurry to apply this, I think, as "no one" constructs 
CameraManagers multiple times... So lets get the second patch ready 
before applying this.

  Tomi


More information about the libcamera-devel mailing list