Re: [PATCH 01/10] sched/topology: introduce for_each_numa_hop_node() / sched_numa_hop_node()
From: Yury Norov
Date: Tue Dec 24 2024 - 12:33:30 EST
> > > + */
> > > +int sched_numa_hop_node(nodemask_t *hop_nodes, int start, unsigned int state)
> > > +{
> > > + int dist, n, min_node, min_dist;
> > > +
> > > + if (state >= NR_NODE_STATES)
> > > + return NUMA_NO_NODE;
> >
> > -EINVAL. But, do we need to check the parameter at all?
>
> numa_nearest_node() has the same check (returning -EINVAL), it seems sane
> to do this check here as well to prevent out-of-bounds access to
> node_states[state].
And I don't think we need to check state in there.
numa_nearest_node() can probably explain it because it's an exported
function. But your sched_numa_hop_node() is an entirely in-kernel thing.
Kernel functions don't check parameters.