[PATCH 3/5] LC15: fix segfault

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Neels Hofmeyr nhofmeyr at sysmocom.de
Tue Mar 22 15:27:09 UTC 2016


On Tue, Mar 22, 2016 at 03:40:10PM +0100, msuraev at sysmocom.de wrote:
> --- a/src/osmo-bts-litecell15/l1_if.h
> +++ b/src/osmo-bts-litecell15/l1_if.h
> @@ -117,8 +117,10 @@ int l1if_ms_pwr_ctrl(struct gsm_lchan *lchan, const int uplink_target,
>  static inline struct lc15l1_hdl *trx_lc15l1_hdl(struct gsm_bts_trx *trx)
>  {
>  	struct phy_instance *pinst = trx_phy_instance(trx);
> -	OSMO_ASSERT(pinst);
> -	return pinst->u.lc15.hdl;
> +	if (pinst)
> +		return pinst->u.lc15.hdl;
> +
> +	return NULL;

So, an OSMO_ASSERT() is typically there to ensure that the code never ends
up breaking the assertion. If the OSMO_ASSERT() ever hits, it would mean
that there's something fatally wrong elsewhere in the code.

Have you checked in this instance that a NULL pinst may be a valid
situation that doesn't need to be asserted upon? If so, I would welcome if
that were mentioned in the log message.

The other chunks above look like pretty obvious improvements, yet maybe
the reasons why they cause segfaults are also elsewhere in the code?
(We don't always check all pointers because we "know" they are fine.)

I have no idea, really, just poking / provoking verbosity ;)

~Neels

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.osmocom.org/pipermail/openbsc/attachments/20160322/7da83511/attachment.bin>


More information about the OpenBSC mailing list