drivers/cpufreq/loongson3_cpufreq.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
devm_mutex_init() may return error, and the avoidance of checking
the error code from devm_mutex_init() call diminishes the point of
using devm variant of it. Add the missed check.
Fixes: ccf51454145b ("cpufreq: Add Loongson-3 CPUFreq driver support")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
drivers/cpufreq/loongson3_cpufreq.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/loongson3_cpufreq.c b/drivers/cpufreq/loongson3_cpufreq.c
index 6b5e6798d9a2..a923e196ec86 100644
--- a/drivers/cpufreq/loongson3_cpufreq.c
+++ b/drivers/cpufreq/loongson3_cpufreq.c
@@ -346,8 +346,11 @@ static int loongson3_cpufreq_probe(struct platform_device *pdev)
{
int i, ret;
- 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)
+ return ret;
+ }
ret = do_service_request(0, 0, CMD_GET_VERSION, 0, 0);
if (ret <= 0)
--
2.34.1
On 05-11-24, 11:20, Jinjie Ruan wrote:
> devm_mutex_init() may return error, and the avoidance of checking
> the error code from devm_mutex_init() call diminishes the point of
> using devm variant of it. Add the missed check.
>
> Fixes: ccf51454145b ("cpufreq: Add Loongson-3 CPUFreq driver support")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> drivers/cpufreq/loongson3_cpufreq.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/loongson3_cpufreq.c b/drivers/cpufreq/loongson3_cpufreq.c
> index 6b5e6798d9a2..a923e196ec86 100644
> --- a/drivers/cpufreq/loongson3_cpufreq.c
> +++ b/drivers/cpufreq/loongson3_cpufreq.c
> @@ -346,8 +346,11 @@ static int loongson3_cpufreq_probe(struct platform_device *pdev)
> {
> int i, ret;
>
> - 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)
> + return ret;
> + }
>
> ret = do_service_request(0, 0, CMD_GET_VERSION, 0, 0);
> if (ret <= 0)
Applied. Thanks.
--
viresh
On 11-11-24, 09:28, Viresh Kumar wrote:
> On 05-11-24, 11:20, Jinjie Ruan wrote:
> > devm_mutex_init() may return error, and the avoidance of checking
> > the error code from devm_mutex_init() call diminishes the point of
> > using devm variant of it. Add the missed check.
> >
> > Fixes: ccf51454145b ("cpufreq: Add Loongson-3 CPUFreq driver support")
> > Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> > ---
> > drivers/cpufreq/loongson3_cpufreq.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/cpufreq/loongson3_cpufreq.c b/drivers/cpufreq/loongson3_cpufreq.c
> > index 6b5e6798d9a2..a923e196ec86 100644
> > --- a/drivers/cpufreq/loongson3_cpufreq.c
> > +++ b/drivers/cpufreq/loongson3_cpufreq.c
> > @@ -346,8 +346,11 @@ static int loongson3_cpufreq_probe(struct platform_device *pdev)
> > {
> > int i, ret;
> >
> > - 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)
> > + return ret;
> > + }
> >
> > ret = do_service_request(0, 0, CMD_GET_VERSION, 0, 0);
> > if (ret <= 0)
>
> Applied. Thanks.
Rather applied the one from Andy as he posted it first.
https://lore.kernel.org/all/20241031134719.2508841-1-andriy.shevchenko@linux.intel.com/
--
viresh
© 2016 - 2026 Red Hat, Inc.