lkml.org 
[lkml]   [2022]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] s390/cpufeature: rework to allow more than only hwcap bits
On Tue, Jul 12, 2022 at 06:46:19PM +0200, Claudio Imbrenda wrote:
> > +int cpu_have_feature(unsigned int num)
> > +{
> > + struct s390_cpu_feature *feature;
> > +
> > + feature = &s390_cpu_features[num];
>
> I would put some check to make sure you are going past the end of the
> array.
>
> Maybe something like
>
> if (num >= MAX_CPU_FEATURES) {
> WARN(1, "Invalid feature %d", num);
> return 0;

That makes sense. I would go for a simple

if (WARN_ON_ONCE(num >= MAX_CPU_FEATURES))
return 0;

\
 
 \ /
  Last update: 2022-07-12 21:45    [W:1.467 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site