[PATCH 3/4] NAT: move BSC config into separate file

Holger Freyther holger at freyther.de
Tue Apr 5 21:00:31 UTC 2016


> On 04 Apr 2016, at 15:30, msuraev at sysmocom.de wrote:
> 

Hi Max,



> +const char *bsc_nat_resolve_path(void *ctx, const char *base, const char *name)
> +{
> +	return ('/' == name[0]) ? name : talloc_asprintf(ctx, "%s/%s", base,
> +							 name);
> +}

I had hinted to you to repeat config reload (and relative paths) and observing memory consumption by using top -p `pidof osmo-bsc_nat`.

This routine is problematic either way in C.


Semantic:

Sometimes new memory will be allocated sometimes not


Responsibility:

Sometimes the callers needs to call talloc_free, sometimes not.


Result:

a.) Caller will never call talloc_free	=> sometimes leaks
b.) Caller will always call talloc_free => sometimes crashes

Solution:

Make the semantic consistent



So please, take this leak and make yourself familiar with valgrind, talloc leak check, etc. It is important to learn from it. See my previous mail for an example how to script it.

kind regards
	holger





More information about the OpenBSC mailing list