drivers: dcvs: memlat: check return value of devm_protocol_get

Validate return value of devm_protocol_get.
Currently only NULL pointer is checked but
we should also check if returned pointer is
valid pointer or not. If it is not valid pointer
then it can lead to crash.

Change-Id: If7c6e275bae0df42511cc915215bfe434d2053e3
Signed-off-by: Shivnandan Kumar <quic_kshivnan@quicinc.com>
This commit is contained in:
Shivnandan Kumar 2022-10-14 12:20:15 +05:30 committed by Gerrit - the friendly Code Review server
parent f6646ebd13
commit 7d10568691

View File

@ -1427,8 +1427,8 @@ int cpucp_memlat_init(struct scmi_device *sdev)
return -EINVAL;
ops = sdev->handle->devm_protocol_get(sdev, SCMI_PROTOCOL_MEMLAT, &ph);
if (!ops)
return -ENODEV;
if (IS_ERR(ops))
return PTR_ERR(ops);
mutex_lock(&memlat_lock);
memlat_data->ph = ph;