Skip to content

Commit

Permalink
res: ucmd-module: return count=0 when sid_ucmd_dev_alias_get_* param …
Browse files Browse the repository at this point in the history
…check fails
  • Loading branch information
prajnoha committed Jul 30, 2024
1 parent 03cd8f7 commit 3a40e32
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions src/resource/ubridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -3619,12 +3619,13 @@ const char **_do_sid_ucmd_dev_alias_get(sid_res_t *mod_res,

const char **sid_ucmd_dev_alias_get(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd_ctx, const char *alias_key, size_t *count)
{
if (!mod_res || !ucmd_ctx)
return NULL;

if (!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->type_mod_reg_res))
if (!mod_res || !ucmd_ctx ||
(!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->type_mod_reg_res))) {
if (count)
*count = 0;
return NULL;
}

return _do_sid_ucmd_dev_alias_get(mod_res, ucmd_ctx, NULL, _owner_name(mod_res), alias_key, count);
}
Expand All @@ -3635,12 +3636,13 @@ const char **sid_ucmd_dev_alias_get_foreign_dev(sid_res_t *mod_res,
const char *alias_key,
size_t *count)
{
if (!mod_res || !ucmd_ctx || UTIL_STR_EMPTY(foreign_dev_id))
return NULL;

if (!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->type_mod_reg_res))
if (!mod_res || !ucmd_ctx || UTIL_STR_EMPTY(foreign_dev_id) ||
(!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->type_mod_reg_res))) {
if (count)
*count = 0;
return NULL;
}

return _do_sid_ucmd_dev_alias_get(mod_res, ucmd_ctx, foreign_dev_id, _owner_name(mod_res), alias_key, count);
}
Expand All @@ -3651,12 +3653,13 @@ const char **sid_ucmd_dev_alias_get_foreign_mod(sid_res_t *mod_res,
const char *alias_key,
size_t *count)
{
if (!mod_res || !ucmd_ctx)
return NULL;

if (!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->type_mod_reg_res))
if (!mod_res || !ucmd_ctx ||
(!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->type_mod_reg_res))) {
if (count)
*count = 0;
return NULL;
}

return _do_sid_ucmd_dev_alias_get(mod_res, ucmd_ctx, NULL, foreign_mod_name, alias_key, count);
}
Expand All @@ -3668,12 +3671,13 @@ const char **sid_ucmd_dev_alias_get_foreign_dev_mod(sid_res_t *mod_res
const char *alias_key,
size_t *count)
{
if (!mod_res || !ucmd_ctx || UTIL_STR_EMPTY(foreign_dev_id))
return NULL;

if (!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->type_mod_reg_res))
if (!mod_res || !ucmd_ctx || UTIL_STR_EMPTY(foreign_dev_id) ||
(!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->block_mod_reg_res) &&
!sid_mod_reg_match_dep(mod_res, ucmd_ctx->common->type_mod_reg_res))) {
if (count)
*count = 0;
return NULL;
}

return _do_sid_ucmd_dev_alias_get(mod_res, ucmd_ctx, foreign_dev_id, foreign_mod_name, alias_key, count);
}
Expand Down

0 comments on commit 3a40e32

Please sign in to comment.