FreeCalypso > hg > fc-magnetite
view cdg-hybrid/cdginc/p_pkt.val @ 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 | e7a67accfad9 |
children |
line wrap: on
line source
/* +--------------------------------------------------------------------------+ | PROJECT : PROTOCOL STACK | | FILE : p_pkt.val | | SOURCE : "sap\pkt.pdf" | | LastModified : "2002-10-17" | | IdAndVersion : "8443.105.02.106" | | SrcFileTime : "Thu Nov 29 09:50:46 2007" | | Generated by CCDGEN_2.5.5A on Fri Oct 14 21:41:52 2016 | | !!DO NOT MODIFY!!DO NOT MODIFY!!DO NOT MODIFY!! | +--------------------------------------------------------------------------+ */ /* PRAGMAS * PREFIX : NONE * COMPATIBILITY_DEFINES : NO (require PREFIX) * ALWAYS_ENUM_IN_VAL_FILE: NO * ENABLE_GROUP: NO * CAPITALIZE_TYPENAME: NO */ #ifndef P_PKT_VAL #define P_PKT_VAL #define CDG_ENTER__P_PKT_VAL #define CDG_ENTER__FILENAME _P_PKT_VAL #define CDG_ENTER__P_PKT_VAL__FILE_TYPE CDGINC #define CDG_ENTER__P_PKT_VAL__LAST_MODIFIED _2002_10_17 #define CDG_ENTER__P_PKT_VAL__ID_AND_VERSION _8443_105_02_106 #define CDG_ENTER__P_PKT_VAL__SRC_FILE_TIME _Thu_Nov_29_09_50_46_2007 #include "CDG_ENTER.h" #undef CDG_ENTER__P_PKT_VAL #undef CDG_ENTER__FILENAME /* * Value constants for VAL_sleep_mode */ #define DIO_SLEEP_ENABLE (0x1) /* Enter sleep mode if possible. */ #define DIO_SLEEP_DISABLE (0x2) /* Do not enter sleep mode. */ /* * Value constants for VAL_parity */ #define DIO_PARITY_NO (0x1) /* Don't send a parity bit. */ #define DIO_PARITY_ODD (0x2) /* Send an odd parity bit. */ #define DIO_PARITY_EVEN (0x4) /* Send an even parity bit. */ #define DIO_PARITY_SPACE (0x8) /* Send a space for parity bit. */ /* * Value constants for VAL_flow_control */ #define DIO_FLOW_NO_NO (0x1) /* No flow control for both directions. */ #define DIO_FLOW_SW_NO (0x2) /* Software flow control for receive direction and no flow control for transmit direction. */ #define DIO_FLOW_HW_NO (0x4) /* Hardware flow control for receive direction and no flow control for transmit direction. */ #define DIO_FLOW_NO_SW (0x8) /* No flow control for receive direction and software flow control for transmit direction. */ #define DIO_FLOW_SW_SW (0x10) /* Software flow control for both directions. */ #define DIO_FLOW_HW_SW (0x20) /* Hardware flow control for receive direction and software flow control for transmit direction. */ #define DIO_FLOW_NO_HW (0x40) /* No flow control for receive direction and hardware flow control for transmit direction. */ #define DIO_FLOW_SW_HW (0x80) /* Software flow control for receive direction and hardware flow control for transmit direction. */ #define DIO_FLOW_HW_HW (0x100) /* Hardware flow control for both directions. */ /* * Value constants for VAL_data_mode */ #define DIO_MODE_AT (0x1) /* The TE will transmit AT commands. */ #define DIO_MODE_DATA (0x2) /* The TE will transmit data. */ #define DIO_MODE_TRACE (0x4) /* The TE expects trace information via this device */ #define DIO_MODE_DEFAULT (0x3) /* Default value if the driver can not provide this information */ /* * Value constants for VAL_stop_bits */ #define DIO_STOP_1 (0x1) /* Send 1 stop bit. */ #define DIO_STOP_15 (0x2) /* Send 1.5 stop bits. */ #define DIO_STOP_2 (0x4) /* Send 2 stop bits. */ /* * Value constants for VAL_baud */ #define DIO_BAUD_812500 (0x80000) /* Transmission rate of 812500 bits/sec. */ #define DIO_BAUD_406250 (0x40000) /* Transmission rate of 406250 bits/sec. */ #define DIO_BAUD_203125 (0x20000) /* Transmission rate of 203125 bits/sec. */ #define DIO_BAUD_115200 (0x10000) /* Transmission rate of 115200 bits/sec. */ #define DIO_BAUD_57600 (0x8000) /* Transmission rate of 57600 bits/sec. */ #define DIO_BAUD_38400 (0x4000) /* Transmission rate of 38400 bits/sec. */ #define DIO_BAUD_33900 (0x2000) /* Transmission rate of 33900 bits/sec. */ #define DIO_BAUD_28800 (0x1000) /* Transmission rate of 28800 bits/sec. */ #define DIO_BAUD_19200 (0x800) /* Transmission rate of 19200 bits/sec. */ #define DIO_BAUD_14400 (0x400) /* Transmission rate of 14400 bits/sec. */ #define DIO_BAUD_9600 (0x200) /* Transmission rate of 9600 bits/sec. */ #define DIO_BAUD_7200 (0x100) /* Transmission rate of 7200 bits/sec. */ #define DIO_BAUD_4800 (0x80) /* Transmission rate of 4800 bits/sec. */ #define DIO_BAUD_2400 (0x40) /* Transmission rate of 2400 bits/sec. */ #define DIO_BAUD_1200 (0x20) /* Transmission rate of 1200 bits/sec. */ #define DIO_BAUD_600 (0x10) /* Transmission rate of 600 bits/sec. */ #define DIO_BAUD_300 (0x8) /* Transmission rate of 300 bits/sec. */ #define DIO_BAUD_150 (0x4) /* Transmission rate of 150 bits/sec. */ #define DIO_BAUD_75 (0x2) /* Transmission rate of 75 bits/sec. */ #define DIO_BAUD_AUTO (0x1) /* Automatic detection. */ /* * Value constants for VAL_mux_configuration */ #define DIO_MUX_MODE_BASIC (0x1) /* The multiplexer supports Basic option. */ #define DIO_MUX_MODE_ADVANCED (0x2) /* The multiplexer supports Advanced option. */ #define DIO_MUX_SUBSET_UIH (0x4) /* The multiplexer supports UIH frames. */ #define DIO_MUX_SUBSET_UI (0x8) /* The multiplexer supports UI frames. */ #define DIO_MUX_SUBSET_I (0x10) /* The multiplexer supports I frames. */ /* * Value constants for VAL_guard_period */ #define DIO_ESC_OFF (0x0) /* Turn escape sequence detection off. */ /* * Value constants for VAL_data_bits */ #define DIO_CHAR_5 (0x10) /* Send 5 bits per character. */ #define DIO_CHAR_6 (0x20) /* Send 6 bits per character. */ #define DIO_CHAR_7 (0x40) /* Send 7 bits per character. */ #define DIO_CHAR_8 (0x80) /* Send 8 bits per character. */ /* * Value constants for VAL_convergence */ #define DIO_CONV_SER (0x1) /* The device can contain serial data. */ #define DIO_CONV_PACKET (0x2) /* The device can contain packet data. */ #define DIO_CONV_MUX (0x4) /* The device can start a multiplexer. */ /* * Value constants for VAL_state */ #define DIO_SA (0x80000000)/* read/write, Device ready */ #define DIO_SB (0x40000000)/* read/write, Data valid */ #define DIO_X (0x20000000)/* read/write, Flow control */ #define DIO_RING (0x10000000)/* write, RING indicator */ #define DIO_ESC (0x8000000)/* read, escape sequence detected */ #define DIO_DISC (0x4000000)/* read, link disconnected */ #define DIO_MUX_STOP (0x1000000)/* read/write, stop the multiplexer */ #define DIO_BRK (0x2000000)/* read/write, break received / to be sent */ #define DIO_BRKLEN (0xff) /* read/write, length of the break signal in characters */ #define DIO_PACKET_UNKNOWN (0x0) /* Packet transfer: No packet type available. */ #define DIO_PACKET_IP (0x21) /* Packet transfer: Simple IP packet */ #define DIO_PACKET_CTCP (0x2d) /* Packet transfer: Van Jacobson compressed TCP/IP header */ #define DIO_PACKET_UTCP (0x2f) /* Packet transfer: Van Jacobson uncompressed TCP/IP header */ /* * Value constants for VAL_cause */ #define PKTCS_SUCCESS (0xd200) /* 0b11010010 00000000 No error, success */ #define PKTCS_INVALID_PARAMS (0xd201) /* 0b11010010 00000001 Device number invalid */ #define PKTCS_INVALID_PEER (0xd202) /* 0b11010010 00000010 Peer does not exist */ #define PKTCS_DISCONNECT (0xd203) /* 0b11010010 00000011 The driver signalled a DRV_SIGTYPE_DISCONNECT */ #define PKTCS_INTERNAL_DRV_ERROR (0xd204) /* 0b11010010 00000100 A driver function returned DRV_INTERNAL_ERROR */ /* * user defined constants */ #define DIO_MAX_NAME_LENGTH (0x10) #define DIO_MAX_DATA_LENGTH (0x64) #include "CDG_LEAVE.h" #endif