On 07/01/2022 19:52, Bjorn Andersson wrote:
When res->regulators is empty num_supplies will be 0 and you will get ZERO_SIZE_PTR back here, so this works just fine - but I had to read the code to learn what kzalloc(0) returns.
Literally as soon as I hit send I realised I hadn't tested the NULL case, then did test it and found this behavior.
Perhaps it would be nice to be explicit and make the allocation conditional on num_supplies? And leave csid->supplies NULL when this happens?
I'll rewrite it, agreed its confusing to look at. --- bod