@@ -94,6 +94,7 @@ int TPM2_IoCb_Zephyr_I2C(TPM2_CTX* ctx, int isRead, word32 addr,
9494{
9595 int ret = 0 ;
9696 byte * tempBuf = NULL ;
97+ (void )userCtx ;
9798
9899 if (buf == NULL ) {
99100 printf ("Buffer passed is NULL" );
@@ -111,11 +112,6 @@ int TPM2_IoCb_Zephyr_I2C(TPM2_CTX* ctx, int isRead, word32 addr,
111112 return -1 ;
112113 }
113114
114- if (userCtx == NULL ) {
115- //printf("UserCtx Cannot be NULL\n");
116- }
117-
118-
119115 /* Init Zephyr I2C Driver */
120116 if (_is_initialized_i2c == 0 ) {
121117 if (TPM2_I2C_Zephyr_Init () != 0 ) {
@@ -129,6 +125,7 @@ int TPM2_IoCb_Zephyr_I2C(TPM2_CTX* ctx, int isRead, word32 addr,
129125 tempBuf = (byte * )XMALLOC (1 , NULL , DYNAMIC_TYPE_TMP_BUFFER );
130126 if (tempBuf == NULL ) {
131127 printf ("Failed to allocate temp buffer\n" );
128+ return -1 ;
132129 }
133130
134131 tempBuf [0 ] = (byte )(addr & 0xFF );
@@ -143,10 +140,10 @@ int TPM2_IoCb_Zephyr_I2C(TPM2_CTX* ctx, int isRead, word32 addr,
143140 }
144141 else {
145142 // Write operation: Register address + Data
146-
147143 tempBuf = (byte * )XMALLOC (size + 1 , NULL , DYNAMIC_TYPE_TMP_BUFFER );
148144 if (tempBuf == NULL ) {
149145 printf ("Failed to allocate temp buffer\n" );
146+ return -1 ;
150147 }
151148
152149 tempBuf [0 ] = (byte )(addr & 0xFF );
@@ -167,8 +164,6 @@ int TPM2_IoCb_Zephyr_I2C(TPM2_CTX* ctx, int isRead, word32 addr,
167164 }
168165 }
169166
170-
171-
172167 (void )ctx ;
173168 return ret ;
174169}
0 commit comments