All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (amd_energy) fix allocation of hwmon_channel_info config
@ 2021-01-07 14:47 David Arcari
  2021-01-08  5:49 ` Chatradhi, Naveen Krishna
  2021-01-08 15:32 ` Guenter Roeck
  0 siblings, 2 replies; 5+ messages in thread
From: David Arcari @ 2021-01-07 14:47 UTC (permalink / raw)
  To: linux-hwmon
  Cc: David Arcari, Naveen Krishna Chatradhi, Jean Delvare,
	Guenter Roeck, linux-kernel, stable

hwmon, specifically hwmon_num_channel_attrs, expects the config
array in the hwmon_channel_info structure to be terminated by
a zero entry.  amd_energy does not honor this convention.  As
result, a KASAN warning is possible.  Fix this by adding an
additional entry and setting it to zero.

Fixes: 8abee9566b7e ("hwmon: Add amd_energy driver to report energy counters")

Signed-off-by: David Arcari <darcari@redhat.com>
Cc: Naveen Krishna Chatradhi <nchatrad@amd.com>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
---
 drivers/hwmon/amd_energy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/amd_energy.c b/drivers/hwmon/amd_energy.c
index 9b306448b7a0..822c2e74b98d 100644
--- a/drivers/hwmon/amd_energy.c
+++ b/drivers/hwmon/amd_energy.c
@@ -222,7 +222,7 @@ static int amd_create_sensor(struct device *dev,
 	 */
 	cpus = num_present_cpus() / num_siblings;
 
-	s_config = devm_kcalloc(dev, cpus + sockets,
+	s_config = devm_kcalloc(dev, cpus + sockets + 1,
 				sizeof(u32), GFP_KERNEL);
 	if (!s_config)
 		return -ENOMEM;
@@ -254,6 +254,7 @@ static int amd_create_sensor(struct device *dev,
 			scnprintf(label_l[i], 10, "Esocket%u", (i - cpus));
 	}
 
+	s_config[i] = 0;
 	return 0;
 }
 
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH] hwmon: (amd_energy) fix allocation of hwmon_channel_info config
  2021-01-07 14:47 [PATCH] hwmon: (amd_energy) fix allocation of hwmon_channel_info config David Arcari
@ 2021-01-08  5:49 ` Chatradhi, Naveen Krishna
  2021-01-08  6:17   ` Guenter Roeck
  2021-01-08 15:32 ` Guenter Roeck
  1 sibling, 1 reply; 5+ messages in thread
From: Chatradhi, Naveen Krishna @ 2021-01-08  5:49 UTC (permalink / raw)
  To: David Arcari, linux-hwmon
  Cc: Jean Delvare, Guenter Roeck, linux-kernel, stable

[AMD Official Use Only - Approved for External Use]

Hi David,

Thank you for noticing and submitting a fix. You may use
Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com>

Regards,
Naveenk

-----Original Message-----
From: David Arcari <darcari@redhat.com> 
Sent: Thursday, January 7, 2021 8:17 PM
To: linux-hwmon@vger.kernel.org
Cc: David Arcari <darcari@redhat.com>; Chatradhi, Naveen Krishna <NaveenKrishna.Chatradhi@amd.com>; Jean Delvare <jdelvare@suse.com>; Guenter Roeck <linux@roeck-us.net>; linux-kernel@vger.kernel.org; stable@vger.kernel.org
Subject: [PATCH] hwmon: (amd_energy) fix allocation of hwmon_channel_info config

[CAUTION: External Email]

hwmon, specifically hwmon_num_channel_attrs, expects the config array in the hwmon_channel_info structure to be terminated by a zero entry.  amd_energy does not honor this convention.  As result, a KASAN warning is possible.  Fix this by adding an additional entry and setting it to zero.

Fixes: 8abee9566b7e ("hwmon: Add amd_energy driver to report energy counters")

Signed-off-by: David Arcari <darcari@redhat.com>
Cc: Naveen Krishna Chatradhi <nchatrad@amd.com>
[naveenk:] Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
---
 drivers/hwmon/amd_energy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/amd_energy.c b/drivers/hwmon/amd_energy.c index 9b306448b7a0..822c2e74b98d 100644
--- a/drivers/hwmon/amd_energy.c
+++ b/drivers/hwmon/amd_energy.c
@@ -222,7 +222,7 @@ static int amd_create_sensor(struct device *dev,
         */
        cpus = num_present_cpus() / num_siblings;

-       s_config = devm_kcalloc(dev, cpus + sockets,
+       s_config = devm_kcalloc(dev, cpus + sockets + 1,
                                sizeof(u32), GFP_KERNEL);
        if (!s_config)
                return -ENOMEM;
@@ -254,6 +254,7 @@ static int amd_create_sensor(struct device *dev,
                        scnprintf(label_l[i], 10, "Esocket%u", (i - cpus));
        }

+       s_config[i] = 0;
        return 0;
 }

--
2.18.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hwmon: (amd_energy) fix allocation of hwmon_channel_info config
  2021-01-08  5:49 ` Chatradhi, Naveen Krishna
@ 2021-01-08  6:17   ` Guenter Roeck
  2021-01-08  6:19     ` Chatradhi, Naveen Krishna
  0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2021-01-08  6:17 UTC (permalink / raw)
  To: Chatradhi, Naveen Krishna, David Arcari, linux-hwmon
  Cc: Jean Delvare, linux-kernel, stable

On 1/7/21 9:49 PM, Chatradhi, Naveen Krishna wrote:
> [AMD Official Use Only - Approved for External Use]
> 
> Hi David,
> 
> Thank you for noticing and submitting a fix. You may use
> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com>
> 

No, because you are not in the approval path (you did not send the patch
to me). Reviewed-by: or Acked-by: would be more appropriate.

Genter

> Regards,
> Naveenk
> 
> -----Original Message-----
> From: David Arcari <darcari@redhat.com> 
> Sent: Thursday, January 7, 2021 8:17 PM
> To: linux-hwmon@vger.kernel.org
> Cc: David Arcari <darcari@redhat.com>; Chatradhi, Naveen Krishna <NaveenKrishna.Chatradhi@amd.com>; Jean Delvare <jdelvare@suse.com>; Guenter Roeck <linux@roeck-us.net>; linux-kernel@vger.kernel.org; stable@vger.kernel.org
> Subject: [PATCH] hwmon: (amd_energy) fix allocation of hwmon_channel_info config
> 
> [CAUTION: External Email]
> 
> hwmon, specifically hwmon_num_channel_attrs, expects the config array in the hwmon_channel_info structure to be terminated by a zero entry.  amd_energy does not honor this convention.  As result, a KASAN warning is possible.  Fix this by adding an additional entry and setting it to zero.
> 
> Fixes: 8abee9566b7e ("hwmon: Add amd_energy driver to report energy counters")
> 
> Signed-off-by: David Arcari <darcari@redhat.com>
> Cc: Naveen Krishna Chatradhi <nchatrad@amd.com>
> [naveenk:] Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: linux-kernel@vger.kernel.org
> Cc: stable@vger.kernel.org
> ---
>  drivers/hwmon/amd_energy.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/amd_energy.c b/drivers/hwmon/amd_energy.c index 9b306448b7a0..822c2e74b98d 100644
> --- a/drivers/hwmon/amd_energy.c
> +++ b/drivers/hwmon/amd_energy.c
> @@ -222,7 +222,7 @@ static int amd_create_sensor(struct device *dev,
>          */
>         cpus = num_present_cpus() / num_siblings;
> 
> -       s_config = devm_kcalloc(dev, cpus + sockets,
> +       s_config = devm_kcalloc(dev, cpus + sockets + 1,
>                                 sizeof(u32), GFP_KERNEL);
>         if (!s_config)
>                 return -ENOMEM;
> @@ -254,6 +254,7 @@ static int amd_create_sensor(struct device *dev,
>                         scnprintf(label_l[i], 10, "Esocket%u", (i - cpus));
>         }
> 
> +       s_config[i] = 0;
>         return 0;
>  }
> 
> --
> 2.18.1
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] hwmon: (amd_energy) fix allocation of hwmon_channel_info config
  2021-01-08  6:17   ` Guenter Roeck
@ 2021-01-08  6:19     ` Chatradhi, Naveen Krishna
  0 siblings, 0 replies; 5+ messages in thread
From: Chatradhi, Naveen Krishna @ 2021-01-08  6:19 UTC (permalink / raw)
  To: Guenter Roeck, David Arcari, linux-hwmon
  Cc: Jean Delvare, linux-kernel, stable

[AMD Official Use Only - Approved for External Use]

Hi Guenter,

>> No, because you are not in the approval path (you did not send the patch to me). Reviewed-by: or Acked-by: would be more appropriate.

Got it, my mistake, please use 
Acked-by: Naveen Krishna Chatradhi <nchatrad@amd.com>

Regards,
Naveenk

-----Original Message-----
From: Guenter Roeck <groeck7@gmail.com> On Behalf Of Guenter Roeck
Sent: Friday, January 8, 2021 11:47 AM
To: Chatradhi, Naveen Krishna <NaveenKrishna.Chatradhi@amd.com>; David Arcari <darcari@redhat.com>; linux-hwmon@vger.kernel.org
Cc: Jean Delvare <jdelvare@suse.com>; linux-kernel@vger.kernel.org; stable@vger.kernel.org
Subject: Re: [PATCH] hwmon: (amd_energy) fix allocation of hwmon_channel_info config

[CAUTION: External Email]

On 1/7/21 9:49 PM, Chatradhi, Naveen Krishna wrote:
> [AMD Official Use Only - Approved for External Use]
>
> Hi David,
>
> Thank you for noticing and submitting a fix. You may use
> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com>
>

No, because you are not in the approval path (you did not send the patch to me). Reviewed-by: or Acked-by: would be more appropriate.

Genter

> Regards,
> Naveenk
>
> -----Original Message-----
> From: David Arcari <darcari@redhat.com>
> Sent: Thursday, January 7, 2021 8:17 PM
> To: linux-hwmon@vger.kernel.org
> Cc: David Arcari <darcari@redhat.com>; Chatradhi, Naveen Krishna 
> <NaveenKrishna.Chatradhi@amd.com>; Jean Delvare <jdelvare@suse.com>; 
> Guenter Roeck <linux@roeck-us.net>; linux-kernel@vger.kernel.org; 
> stable@vger.kernel.org
> Subject: [PATCH] hwmon: (amd_energy) fix allocation of 
> hwmon_channel_info config
>
> [CAUTION: External Email]
>
> hwmon, specifically hwmon_num_channel_attrs, expects the config array in the hwmon_channel_info structure to be terminated by a zero entry.  amd_energy does not honor this convention.  As result, a KASAN warning is possible.  Fix this by adding an additional entry and setting it to zero.
>
> Fixes: 8abee9566b7e ("hwmon: Add amd_energy driver to report energy 
> counters")
>
> Signed-off-by: David Arcari <darcari@redhat.com>
> Cc: Naveen Krishna Chatradhi <nchatrad@amd.com> [naveenk:] 
> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: linux-kernel@vger.kernel.org
> Cc: stable@vger.kernel.org
> ---
>  drivers/hwmon/amd_energy.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/amd_energy.c b/drivers/hwmon/amd_energy.c 
> index 9b306448b7a0..822c2e74b98d 100644
> --- a/drivers/hwmon/amd_energy.c
> +++ b/drivers/hwmon/amd_energy.c
> @@ -222,7 +222,7 @@ static int amd_create_sensor(struct device *dev,
>          */
>         cpus = num_present_cpus() / num_siblings;
>
> -       s_config = devm_kcalloc(dev, cpus + sockets,
> +       s_config = devm_kcalloc(dev, cpus + sockets + 1,
>                                 sizeof(u32), GFP_KERNEL);
>         if (!s_config)
>                 return -ENOMEM;
> @@ -254,6 +254,7 @@ static int amd_create_sensor(struct device *dev,
>                         scnprintf(label_l[i], 10, "Esocket%u", (i - cpus));
>         }
>
> +       s_config[i] = 0;
>         return 0;
>  }
>
> --
> 2.18.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hwmon: (amd_energy) fix allocation of hwmon_channel_info config
  2021-01-07 14:47 [PATCH] hwmon: (amd_energy) fix allocation of hwmon_channel_info config David Arcari
  2021-01-08  5:49 ` Chatradhi, Naveen Krishna
@ 2021-01-08 15:32 ` Guenter Roeck
  1 sibling, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2021-01-08 15:32 UTC (permalink / raw)
  To: David Arcari
  Cc: linux-hwmon, Naveen Krishna Chatradhi, Jean Delvare,
	linux-kernel, stable

On Thu, Jan 07, 2021 at 09:47:07AM -0500, David Arcari wrote:
> hwmon, specifically hwmon_num_channel_attrs, expects the config
> array in the hwmon_channel_info structure to be terminated by
> a zero entry.  amd_energy does not honor this convention.  As
> result, a KASAN warning is possible.  Fix this by adding an
> additional entry and setting it to zero.
> 
> Fixes: 8abee9566b7e ("hwmon: Add amd_energy driver to report energy counters")
> 
> Signed-off-by: David Arcari <darcari@redhat.com>
> Cc: Naveen Krishna Chatradhi <nchatrad@amd.com>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: linux-kernel@vger.kernel.org
> Cc: stable@vger.kernel.org
> Signed-off-by: David Arcari <darcari@redhat.com>
> Acked-by: Naveen Krishna Chatradhi <nchatrad@amd.com>

Applied.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-08 15:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07 14:47 [PATCH] hwmon: (amd_energy) fix allocation of hwmon_channel_info config David Arcari
2021-01-08  5:49 ` Chatradhi, Naveen Krishna
2021-01-08  6:17   ` Guenter Roeck
2021-01-08  6:19     ` Chatradhi, Naveen Krishna
2021-01-08 15:32 ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.