Hi Daniel,

I realized small issue when I went through this new mutex code
(which is safer IMHO).

On 12/1/20 7:28 PM, Daniel Lezcano wrote:

[snip]

+int dtpm_register(const char *name, struct dtpm *dtpm, struct dtpm *parent)
+{
+       struct powercap_zone *pcz;
+
+       if (!pct)
+               return -EAGAIN;
+
+       if (root && !parent)
+               return -EBUSY;
+
+       if (!root && parent)
+               return -EINVAL;
+
+       if (parent && parent->ops)
+               return -EINVAL;
+

Maybe it worth to add a check of dtpm pointer here, just to play safe?

        if (!dtpm)
                return -EINVAL;

The dtpm->ops might explode when we don't capture this miss-usage during
reviews of future drivers/shim layers. What do you think?


+       if (dtpm->ops && !(dtpm->ops->set_power_uw &&
+                          dtpm->ops->get_power_uw &&
+                          dtpm->ops->release))
+               return -EINVAL;
+

I am going to stress test the whole series with hotplug today
and add review for patch 4/4.

Regards,
Lukasz

Reply via email to