diff --git a/upatch-manage/patch_entity.h b/upatch-manage/patch_entity.h index 6035aacfd4344cbffcb57b78983eeb86587ff34f..1f4be0670131c22e8ca69b64dfe9b69f1c64f8b6 100644 --- a/upatch-manage/patch_entity.h +++ b/upatch-manage/patch_entity.h @@ -22,6 +22,7 @@ #define _UPATCH_MANAGE_PATCH_ENTITY_H #include +#include #include #include #include @@ -145,7 +146,7 @@ void release_patch(struct kref *kref); */ static inline struct patch_entity *get_patch(struct patch_entity *patch) { - if (unlikely(!patch)) { + if (unlikely(IS_ERR_OR_NULL(patch))) { return NULL; } @@ -162,7 +163,7 @@ static inline struct patch_entity *get_patch(struct patch_entity *patch) */ static inline void put_patch(struct patch_entity *patch) { - if (unlikely(!patch)) { + if (unlikely(IS_ERR_OR_NULL(patch))) { return; } diff --git a/upatch-manage/patch_manage.c b/upatch-manage/patch_manage.c index c0e238aa023ce297a51f1da550bf46607d4d4d0d..12409f1bd4bcc3e9682da9d7f04c52cdd621d49a 100644 --- a/upatch-manage/patch_manage.c +++ b/upatch-manage/patch_manage.c @@ -239,6 +239,7 @@ int upatch_load(const char *target_file, const char *patch_file) new_target = load_target(file); if (unlikely(IS_ERR(new_target))) { ret = PTR_ERR(new_target); + new_target = NULL; log_err("failed to load target %s, ret=%d\n", target_file, ret); goto release_out; } diff --git a/upatch-manage/process_entity.h b/upatch-manage/process_entity.h index de6635a8c5199ccd8b96d70349109c585da2e954..53f172e655d46b98ee672a2a275a3217ce4e5e9a 100644 --- a/upatch-manage/process_entity.h +++ b/upatch-manage/process_entity.h @@ -22,7 +22,8 @@ #define _UPATCH_MANAGE_PROCESS_ENTITY_H #include -#include +#include + #include #include #include @@ -112,7 +113,7 @@ void release_process(struct kref *kref); */ static inline struct process_entity *get_process(struct process_entity *process) { - if (unlikely(!process)) { + if (unlikely(IS_ERR_OR_NULL(process))) { return NULL; } @@ -129,7 +130,7 @@ static inline struct process_entity *get_process(struct process_entity *process) */ static inline void put_process(struct process_entity *process) { - if (unlikely(!process)) { + if (unlikely(IS_ERR_OR_NULL(process))) { return; } diff --git a/upatch-manage/target_entity.h b/upatch-manage/target_entity.h index 7c0b96cd858e3814a0e2a117aff0d4f7a4189c9b..6f07f848c589e003f0ce9c04938b04e9876b224a 100644 --- a/upatch-manage/target_entity.h +++ b/upatch-manage/target_entity.h @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -150,7 +151,7 @@ void release_target(struct kref *kref); */ static inline struct target_entity *get_target(struct target_entity *target) { - if (unlikely(!target)) { + if (unlikely(IS_ERR_OR_NULL(target))) { return NULL; } @@ -167,7 +168,7 @@ static inline struct target_entity *get_target(struct target_entity *target) */ static inline void put_target(struct target_entity *target) { - if (unlikely(!target)) { + if (unlikely(IS_ERR_OR_NULL(target))) { return; }