power: Add callback parameter check 10/300910/2 accepted/tizen/7.0/unified/20231107.145940
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 04:01:18 +0000 (13:01 +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 82ba3ae1b19017039f9f311a1696e933238338c2..8fac068f77ab717560609c40867e0393529178c8 100644 (file)
@@ -200,6 +200,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);
 }
 
@@ -311,6 +314,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);
 }