diff mbox series

thermal: intel: quark_dts: fix error pointer dereference

Message ID Y/yAusqpje3MqS1N@kili (mailing list archive)
State Mainlined, archived
Headers show
Series thermal: intel: quark_dts: fix error pointer dereference | expand

Commit Message

Dan Carpenter Feb. 27, 2023, 10:06 a.m. UTC
If alloc_soc_dts() fails, then we can just return.  Trying to free
"soc_dts" will lead to an Oops.

Fixes: 8c1876939663 ("thermal: intel Quark SoC X1000 DTS thermal driver")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
 drivers/thermal/intel/intel_quark_dts_thermal.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

Comments

Rafael J. Wysocki March 1, 2023, 6:30 p.m. UTC | #1
On Mon, Feb 27, 2023 at 11:06 AM Dan Carpenter <error27@gmail.com> wrote:
>
> If alloc_soc_dts() fails, then we can just return.  Trying to free
> "soc_dts" will lead to an Oops.
>
> Fixes: 8c1876939663 ("thermal: intel Quark SoC X1000 DTS thermal driver")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
>  drivers/thermal/intel/intel_quark_dts_thermal.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/thermal/intel/intel_quark_dts_thermal.c b/drivers/thermal/intel/intel_quark_dts_thermal.c
> index 97b843fa7568..ffdc95047838 100644
> --- a/drivers/thermal/intel/intel_quark_dts_thermal.c
> +++ b/drivers/thermal/intel/intel_quark_dts_thermal.c
> @@ -400,22 +400,14 @@ MODULE_DEVICE_TABLE(x86cpu, qrk_thermal_ids);
>
>  static int __init intel_quark_thermal_init(void)
>  {
> -       int err = 0;
> -
>         if (!x86_match_cpu(qrk_thermal_ids) || !iosf_mbi_available())
>                 return -ENODEV;
>
>         soc_dts = alloc_soc_dts();
> -       if (IS_ERR(soc_dts)) {
> -               err = PTR_ERR(soc_dts);
> -               goto err_free;
> -       }
> +       if (IS_ERR(soc_dts))
> +               return PTR_ERR(soc_dts);
>
>         return 0;
> -
> -err_free:
> -       free_soc_dts(soc_dts);
> -       return err;
>  }
>
>  static void __exit intel_quark_thermal_exit(void)
> --

Applied as 6.3-rc material, thanks!
diff mbox series

Patch

diff --git a/drivers/thermal/intel/intel_quark_dts_thermal.c b/drivers/thermal/intel/intel_quark_dts_thermal.c
index 97b843fa7568..ffdc95047838 100644
--- a/drivers/thermal/intel/intel_quark_dts_thermal.c
+++ b/drivers/thermal/intel/intel_quark_dts_thermal.c
@@ -400,22 +400,14 @@  MODULE_DEVICE_TABLE(x86cpu, qrk_thermal_ids);
 
 static int __init intel_quark_thermal_init(void)
 {
-	int err = 0;
-
 	if (!x86_match_cpu(qrk_thermal_ids) || !iosf_mbi_available())
 		return -ENODEV;
 
 	soc_dts = alloc_soc_dts();
-	if (IS_ERR(soc_dts)) {
-		err = PTR_ERR(soc_dts);
-		goto err_free;
-	}
+	if (IS_ERR(soc_dts))
+		return PTR_ERR(soc_dts);
 
 	return 0;
-
-err_free:
-	free_soc_dts(soc_dts);
-	return err;
 }
 
 static void __exit intel_quark_thermal_exit(void)