lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZyMsr0JrXne-h4r8@smile.fi.intel.com>
Date: Thu, 31 Oct 2024 09:07:27 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Huacai Chen <chenhuacai@...nel.org>
Cc: Viresh Kumar <viresh.kumar@...aro.org>, loongarch@...ts.linux.dev,
	linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
	WANG Xuerui <kernel@...0n.name>,
	"Rafael J. Wysocki" <rafael@...nel.org>
Subject: Re: [PATCH v1 1/1] cpufreq: loongson: Check for error code from
 devm_mutex_init() call

On Thu, Oct 31, 2024 at 09:29:52AM +0800, Huacai Chen wrote:
> On Thu, Oct 31, 2024 at 12:29 AM Andy Shevchenko
> <andriy.shevchenko@...ux.intel.com> wrote:

...

> > -       for (i = 0; i < MAX_PACKAGES; i++)
> > -               devm_mutex_init(&pdev->dev, &cpufreq_mutex[i]);
> > +       for (i = 0; i < MAX_PACKAGES; i++) {
> > +               ret = devm_mutex_init(&pdev->dev, &cpufreq_mutex[i]);
> > +               if (ret)
> Good catch, but I think "if (ret < 0)" is better? Sometimes a positive
> return value is legal, even if not in this case.

I disagree on this.

During a tons of reviews I have done in the past this kind of check is
impediment and always rises the Q "why?" It means that the author hasn't
fully thought through the code and most likely done something is a cargo cult.
On top of that, if the callee is changed at some point to actually return
a positive code(s), the caller most likely has to be at least aware of that
change. The proposed modification makes this silently compile and hides
possible important details from the caller(s).

> And it is better to use loongson3 rather than loongson because there
>  is another loongson2 driver.

Thanks, I will change that in v2 (I believe you are talking about Subject?).

> > +                       return ret;
> > +       }

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ