power: Add callback parameter check 23/300923/1 accepted/tizen/unified/20231107.172855
authorYunhee Seo <yuni.seo@samsung.com>
Mon, 6 Nov 2023 01:46:15 +0000 (10:46 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Mon, 6 Nov 2023 05:15:57 +0000 (14:15 +0900)
When the callback parameter is null, it causes abnormal operation.
To avoid this, callback parameter check is necessary.

Change-Id: I5bfdf967ed5abea9563cbe070d8157b47d5ec7b0
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
src/power-internal.c

index 631e11a..74d2b1e 100644 (file)
@@ -201,6 +201,9 @@ int device_power_add_state_wait_callback(device_power_state_e state_bits,
        if (!IS_STATE_BIT(state_bits))
                return DEVICE_ERROR_INVALID_PARAMETER;
 
+       if (!cb)
+               return DEVICE_ERROR_INVALID_PARAMETER;
+
        return register_state_signal_callback(state_bits, cb, data);
 }
 
@@ -312,6 +315,9 @@ int device_power_add_transient_state_wait_callback(device_power_transient_state_
        if (!IS_TRANSIENT_STATE_BIT(transient_bits))
                return DEVICE_ERROR_INVALID_PARAMETER;
 
+       if (!cb)
+               return DEVICE_ERROR_INVALID_PARAMETER;
+
        return register_transient_state_signal_callback(transient_bits, cb, data);
 }