FreeCalypso > hg > fc-magnetite
annotate src/gpf2/frame/route.h @ 516:1ed9de6c90bd
src/g23m-gsm/sms/sms_for.c: bogus malloc removed
The new error handling code that was not present in TCS211 blob version
contains a malloc call that is bogus for 3 reasons:
1) The memory allocation in question is not needed in the first place;
2) libc malloc is used instead of one of the firmware's proper ways;
3) The memory allocation is made inside a function and then never freed,
i.e., a memory leak.
This bug was caught in gcc-built FreeCalypso fw projects (Citrine
and Selenite) because our gcc environment does not allow any use of
libc malloc (any reference to malloc produces a link failure),
but this code from TCS3.2 is wrong even for Magnetite: if this code
path is executed repeatedly over a long time, the many small allocations
made by this malloc call without a subsequent free will eventually
exhaust the malloc heap provided by the TMS470 environment, malloc will
start returning NULL, and the bogus code will treat it as an error.
Because the memory allocation in question is not needed at all,
the fix entails simply removing it.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 22 Jul 2018 06:04:49 +0000 |
parents | 864b8cc0cf63 |
children |
rev | line source |
---|---|
1
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 +----------------------------------------------------------------------------- |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 | File: route.h |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 +----------------------------------------------------------------------------- |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 | Copyright 2002 Texas Instruments Berlin, AG |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 | All rights reserved. |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 | |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 | This file is confidential and a trade secret of Texas |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 | Instruments Berlin, AG |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 | The receipt of or possession of this file does not convey |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 | any rights to reproduce or disclose its contents or to |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 | manufacture, use, or sell anything it may describe, in |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 | whole, or in part, without the specific written consent of |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 | Texas Instruments Berlin, AG. |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 +----------------------------------------------------------------------------- |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 | Purpose : Type definitions and prototypes for routing. |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 +----------------------------------------------------------------------------- |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 */ |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #ifndef __ROUTE_H__ |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #define __ROUTE_H__ |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 #define RT_DUPLICATE 0x01 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #define RT_REDIRECT 0x02 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 #define RT_DESTROY 0x04 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 #define RT_COMMAND_MASK (RT_DUPLICATE|RT_REDIRECT|RT_DESTROY) |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 #define RT_CLEAR_ENTRY 0x10 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #define RT_ALL_DESTINATION 0x20 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 typedef enum { RT_STORE = 1, RT_DELETE } RT_ENTRY; |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 typedef enum { RT_PRIMITIVE_TYPE = 1, RT_SIGNAL_TYPE, RT_TIMEOUT_TYPE } RT_MESSAGE_TYPE; |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 typedef struct _T_ROUTING_ENTRY |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 { |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 T_HANDLE SndTaskHandle; /* sender of a mesage */ |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 T_HANDLE OldDestComHandle; /* original destination queue handle */ |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 T_HANDLE OldDestTaskHandle;/* original destination task handle */ |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 T_HANDLE NewDestComHandle; /* new destination queue handle */ |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 RT_MESSAGE_TYPE MsgType; /* message type (primitive,timeout,signal) */ |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 ULONG opcStatus; /* mask for messages to be routed */ |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 ULONG opcMask; /* relevant bits in opcStatus */ |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 int Command; /* redirect/duplicate */ |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 char ExtDest[RESOURCE_NAMELEN]; |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 struct _T_ROUTING_ENTRY * pNextEntry; |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 struct _T_ROUTING_ENTRY * pPrevEntry; |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } T_FRM_ROUTING_TABLE_ENTRY; |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 #define RT_OK 0 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 #define RT_ERROR (-1) |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 #define RT_NO_MEM (-2) |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 #define ROUTE_ALL (T_HANDLE)0xFFFF |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 #define RT_CLEAR_TOKEN "CLEAR" |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 #define RT_ALL_TOKEN "ALL" |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 #define RT_SIGNAL_TOKEN "S" |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 #define RT_TIMEOUT_TOKEN "T" |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 GLOBAL SHORT rt_Init (void); |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 GLOBAL SHORT rt_RoutingModify ( T_HANDLE TaskHandle, char *Command, char *String); |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 GLOBAL SHORT rt_ConnectRoute ( T_HANDLE TaskHandle, char *Destination); |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 GLOBAL SHORT rt_DisconnectRoute ( T_HANDLE TaskHandle, char *Destination); |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 GLOBAL SHORT rt_Route ( T_HANDLE SndTaskHandle, T_HANDLE RcvComHandle, USHORT Prio, ULONG Suspend, OS_QDATA *Msg ); |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 GLOBAL SHORT rt_RouteRead ( T_HANDLE TaskHandle, char *token ); |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 GLOBAL void rt_ExtPrimitive ( T_HANDLE TaskHandle, T_HANDLE DestComHandle, T_HANDLE OrgDestComHandle, char *ExtDest, OS_QDATA *Msg ) ; |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 GLOBAL SHORT rt_isolate_entity ( T_HANDLE caller, char *entity ); |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 GLOBAL int rt_desclist_to_sdu ( T_HANDLE caller, T_HANDLE dst, T_PRIM_HEADER *prim, T_PRIM_HEADER **sdu_prim ); |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 |
864b8cc0cf63
src/gpf2: preened GPF goo from TCS211
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 #endif /* ROUTE_H */ |