Skip to content

Commit 7a155d1

Browse files
committed
issue: 4583806 Coverity var_deref_op and var_deref_model fixes
Fix Coverity-reported null pointer dereference warnings by adding explicit null checks and Coverity suppression comments to document intentional pointer dereferencing after validation, eliminating false positives. Changes: - Refactored SYSCALL macro to use statement expression with explicit if/else for clearer control flow to Coverity static analyzer - Added suppression comment for dbrec pointer which is guaranteed valid after successful xlio_ib_mlx5dv_init_obj() call - Added suppression comment for p_iov pointer which is validated before reaching OS transmit fallback path Updated files: - src/core/sock/sock-redirect.h - src/core/ib/mlx5/ib_mlx5.cpp - libxlio/src/core/ib/mlx5/ib_mlx5.cpp - src/core/sock/sockinfo_udp.cpp - libxlio/src/core/sock/sockinfo_udp.cpp Signed-off-by: Omri Ritblat <[email protected]>
1 parent 169f224 commit 7a155d1

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/core/config/descriptor_providers/schema_analyzer.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,13 @@ constraint_config schema_analyzer::analyze_constraint_config()
218218
for_each_oneof_option(one_of_field, [&](json_object *option) {
219219
json_object *type_field =
220220
json_utils::get_field(option, config_strings::schema::JSON_TYPE);
221-
std::string type_str = json_object_get_string(type_field);
222-
if (type_str == config_strings::schema_types::JSON_TYPE_INTEGER) {
223-
extract_constraints_from_json(option, config);
224-
}
221+
const char *type_cstr = json_object_get_string(type_field);
222+
if (type_cstr) {
223+
std::string type_str = type_cstr;
224+
if (type_str == config_strings::schema_types::JSON_TYPE_INTEGER) {
225+
extract_constraints_from_json(option, config);
226+
}
227+
}
225228
});
226229
}
227230

src/core/ib/mlx5/ib_mlx5.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ int xlio_ib_mlx5_get_qp_tx(xlio_ib_mlx5_qp_t *mlx5_qp)
3838

3939
VALGRIND_MAKE_MEM_DEFINED(&dqp, sizeof(dqp));
4040
mlx5_qp->qpn = mlx5_qp->qp->qp_num;
41+
/* coverity[var_deref_op] dbrec is guaranteed to be valid after successful xlio_ib_mlx5dv_init_obj */
4142
mlx5_qp->sq.dbrec = &dqp.dbrec[MLX5_SND_DBR];
4243
mlx5_qp->sq.buf = dqp.sq.buf;
4344
mlx5_qp->sq.wqe_cnt = dqp.sq.wqe_cnt;

src/core/sock/sockinfo_udp.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2187,7 +2187,12 @@ ssize_t sockinfo_udp::tx(xlio_tx_call_attr_t &tx_arg)
21872187

21882188
tx_packet_to_os:
21892189
// Calling OS transmit
2190-
ret = tx_os(tx_arg.opcode, p_iov, sz_iov, __flags, __dst, __dstlen);
2190+
if (unlikely(!p_iov)) {
2191+
errno = EINVAL;
2192+
ret = -1;
2193+
} else {
2194+
ret = tx_os(tx_arg.opcode, p_iov, sz_iov, __flags, __dst, __dstlen);
2195+
}
21912196

21922197
tx_packet_to_os_stats:
21932198
save_stats_tx_os(ret);

0 commit comments

Comments
 (0)