All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] coresight: Don't allocate pdata->conns when there is no output port
@ 2020-09-08  7:31 ` Qi Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Qi Liu @ 2020-09-08  7:31 UTC (permalink / raw)
  To: mathieu.poirier, suzuki.poulose, Al.Grant
  Cc: linux-kernel, linux-arm-kernel, linuxarm

When there is no output port, coresight_alloc_conns() still do the following
copy connection information to pdata->conns, and this may cause kernel panic.
Let's fix it.

Signed-off-by: Qi Liu <liuqi115@huawei.com>
---
 drivers/hwtracing/coresight/coresight-platform.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
index bfd4423..cdc8824 100644
--- a/drivers/hwtracing/coresight/coresight-platform.c
+++ b/drivers/hwtracing/coresight/coresight-platform.c
@@ -26,12 +26,13 @@
 static int coresight_alloc_conns(struct device *dev,
 				 struct coresight_platform_data *pdata)
 {
-	if (pdata->nr_outport) {
-		pdata->conns = devm_kcalloc(dev, pdata->nr_outport,
-					    sizeof(*pdata->conns), GFP_KERNEL);
-		if (!pdata->conns)
-			return -ENOMEM;
-	}
+	if (!pdata->nr_outport)
+		return -ENOMEM;
+
+	pdata->conns = devm_kcalloc(dev, pdata->nr_outport,
+				    sizeof(*pdata->conns), GFP_KERNEL);
+	if (!pdata->conns)
+		return -ENOMEM;

 	return 0;
 }
--
2.8.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH] coresight: Don't allocate pdata->conns when there is no output port
@ 2020-09-08  7:31 ` Qi Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Qi Liu @ 2020-09-08  7:31 UTC (permalink / raw)
  To: mathieu.poirier, suzuki.poulose, Al.Grant
  Cc: linux-arm-kernel, linux-kernel, linuxarm

When there is no output port, coresight_alloc_conns() still do the following
copy connection information to pdata->conns, and this may cause kernel panic.
Let's fix it.

Signed-off-by: Qi Liu <liuqi115@huawei.com>
---
 drivers/hwtracing/coresight/coresight-platform.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
index bfd4423..cdc8824 100644
--- a/drivers/hwtracing/coresight/coresight-platform.c
+++ b/drivers/hwtracing/coresight/coresight-platform.c
@@ -26,12 +26,13 @@
 static int coresight_alloc_conns(struct device *dev,
 				 struct coresight_platform_data *pdata)
 {
-	if (pdata->nr_outport) {
-		pdata->conns = devm_kcalloc(dev, pdata->nr_outport,
-					    sizeof(*pdata->conns), GFP_KERNEL);
-		if (!pdata->conns)
-			return -ENOMEM;
-	}
+	if (!pdata->nr_outport)
+		return -ENOMEM;
+
+	pdata->conns = devm_kcalloc(dev, pdata->nr_outport,
+				    sizeof(*pdata->conns), GFP_KERNEL);
+	if (!pdata->conns)
+		return -ENOMEM;

 	return 0;
 }
--
2.8.1


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

* Re: [PATCH] coresight: Don't allocate pdata->conns when there is no output port
  2020-09-08  7:31 ` Qi Liu
@ 2020-09-11 17:59   ` Mathieu Poirier
  -1 siblings, 0 replies; 4+ messages in thread
From: Mathieu Poirier @ 2020-09-11 17:59 UTC (permalink / raw)
  To: Qi Liu; +Cc: linuxarm, Al.Grant, linux-kernel, linux-arm-kernel,
	suzuki.poulose

Hi Liu,

On Tue, Sep 08, 2020 at 03:31:28PM +0800, Qi Liu wrote:
> When there is no output port, coresight_alloc_conns() still do the following
> copy connection information to pdata->conns, and this may cause kernel panic.
> Let's fix it.

Function coresight_alloc_conns() doesn't copy connection information.  Moreover
sink devices don't have an output port and this code has been stable for years
now.  As such I am suspecting that something else is going wrong...

Can you give more details about the coresight topology you are working with?  An
output of the kernel panic you are seeing would also be much appreciated.

Thanks,
Mathieu

> 
> Signed-off-by: Qi Liu <liuqi115@huawei.com>
> ---
>  drivers/hwtracing/coresight/coresight-platform.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
> index bfd4423..cdc8824 100644
> --- a/drivers/hwtracing/coresight/coresight-platform.c
> +++ b/drivers/hwtracing/coresight/coresight-platform.c
> @@ -26,12 +26,13 @@
>  static int coresight_alloc_conns(struct device *dev,
>  				 struct coresight_platform_data *pdata)
>  {
> -	if (pdata->nr_outport) {
> -		pdata->conns = devm_kcalloc(dev, pdata->nr_outport,
> -					    sizeof(*pdata->conns), GFP_KERNEL);
> -		if (!pdata->conns)
> -			return -ENOMEM;
> -	}
> +	if (!pdata->nr_outport)
> +		return -ENOMEM;
> +
> +	pdata->conns = devm_kcalloc(dev, pdata->nr_outport,
> +				    sizeof(*pdata->conns), GFP_KERNEL);
> +	if (!pdata->conns)
> +		return -ENOMEM;
> 
>  	return 0;
>  }
> --
> 2.8.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] coresight: Don't allocate pdata->conns when there is no output port
@ 2020-09-11 17:59   ` Mathieu Poirier
  0 siblings, 0 replies; 4+ messages in thread
From: Mathieu Poirier @ 2020-09-11 17:59 UTC (permalink / raw)
  To: Qi Liu; +Cc: suzuki.poulose, Al.Grant, linux-arm-kernel, linux-kernel,
	linuxarm

Hi Liu,

On Tue, Sep 08, 2020 at 03:31:28PM +0800, Qi Liu wrote:
> When there is no output port, coresight_alloc_conns() still do the following
> copy connection information to pdata->conns, and this may cause kernel panic.
> Let's fix it.

Function coresight_alloc_conns() doesn't copy connection information.  Moreover
sink devices don't have an output port and this code has been stable for years
now.  As such I am suspecting that something else is going wrong...

Can you give more details about the coresight topology you are working with?  An
output of the kernel panic you are seeing would also be much appreciated.

Thanks,
Mathieu

> 
> Signed-off-by: Qi Liu <liuqi115@huawei.com>
> ---
>  drivers/hwtracing/coresight/coresight-platform.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
> index bfd4423..cdc8824 100644
> --- a/drivers/hwtracing/coresight/coresight-platform.c
> +++ b/drivers/hwtracing/coresight/coresight-platform.c
> @@ -26,12 +26,13 @@
>  static int coresight_alloc_conns(struct device *dev,
>  				 struct coresight_platform_data *pdata)
>  {
> -	if (pdata->nr_outport) {
> -		pdata->conns = devm_kcalloc(dev, pdata->nr_outport,
> -					    sizeof(*pdata->conns), GFP_KERNEL);
> -		if (!pdata->conns)
> -			return -ENOMEM;
> -	}
> +	if (!pdata->nr_outport)
> +		return -ENOMEM;
> +
> +	pdata->conns = devm_kcalloc(dev, pdata->nr_outport,
> +				    sizeof(*pdata->conns), GFP_KERNEL);
> +	if (!pdata->conns)
> +		return -ENOMEM;
> 
>  	return 0;
>  }
> --
> 2.8.1
> 

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

end of thread, other threads:[~2020-09-11 18:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-08  7:31 [PATCH] coresight: Don't allocate pdata->conns when there is no output port Qi Liu
2020-09-08  7:31 ` Qi Liu
2020-09-11 17:59 ` Mathieu Poirier
2020-09-11 17:59   ` Mathieu Poirier

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.