All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/exynos: gsc: Variable "gscblk_cfg" in function gsc_set_gscblk_fimd_wb() could be uninitialized
@ 2019-01-28 18:28   ` Yizhuo
  0 siblings, 0 replies; 6+ messages in thread
From: Yizhuo @ 2019-01-28 18:28 UTC (permalink / raw)
  Cc: csong, zhiyunq, Yizhuo, Inki Dae, Joonyoung Shim, Seung-Woo Kim,
	Kyungmin Park, David Airlie, Kukjin Kim, Krzysztof Kozlowski,
	dri-devel, linux-arm-kernel, linux-samsung-soc, linux-kernel

In function gsc_set_gscblk_fimd_wb(), local variable "gscblk_cfg"
could be uninitialized of function regmap_read returns -EINVAL.
However, this value will be  write to the register after "or"
operation. This is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/gpu/drm/exynos/exynos_drm_gsc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
index 0506b2b17ac1..b1d0f974fe80 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
@@ -441,11 +441,16 @@ static int gsc_sw_reset(struct gsc_context *ctx)
 static void gsc_set_gscblk_fimd_wb(struct gsc_context *ctx, bool enable)
 {
 	unsigned int gscblk_cfg;
+	int ret;
 
 	if (!ctx->sysreg)
 		return;
 
-	regmap_read(ctx->sysreg, SYSREG_GSCBLK_CFG1, &gscblk_cfg);
+	ret = regmap_read(ctx->sysreg, SYSREG_GSCBLK_CFG1, &gscblk_cfg);
+	if (ret) {
+		DRM_ERROR("gsc: Fail to read system register\n");
+		return;
+	}
 
 	if (enable)
 		gscblk_cfg |= GSC_BLK_DISP1WB_DEST(ctx->id) |
-- 
2.17.1


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

* [PATCH] drm/exynos: gsc: Variable "gscblk_cfg" in function gsc_set_gscblk_fimd_wb() could be uninitialized
@ 2019-01-28 18:28   ` Yizhuo
  0 siblings, 0 replies; 6+ messages in thread
From: Yizhuo @ 2019-01-28 18:28 UTC (permalink / raw)
  Cc: csong, zhiyunq, Yizhuo, Inki Dae, Joonyoung Shim, Seung-Woo Kim,
	Kyungmin Park, David Airlie, Kukjin Kim, Krzysztof Kozlowski,
	dri-devel, linux-arm-kernel, linux-samsung-soc, linux-kernel

In function gsc_set_gscblk_fimd_wb(), local variable "gscblk_cfg"
could be uninitialized of function regmap_read returns -EINVAL.
However, this value will be  write to the register after "or"
operation. This is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/gpu/drm/exynos/exynos_drm_gsc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
index 0506b2b17ac1..b1d0f974fe80 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
@@ -441,11 +441,16 @@ static int gsc_sw_reset(struct gsc_context *ctx)
 static void gsc_set_gscblk_fimd_wb(struct gsc_context *ctx, bool enable)
 {
 	unsigned int gscblk_cfg;
+	int ret;
 
 	if (!ctx->sysreg)
 		return;
 
-	regmap_read(ctx->sysreg, SYSREG_GSCBLK_CFG1, &gscblk_cfg);
+	ret = regmap_read(ctx->sysreg, SYSREG_GSCBLK_CFG1, &gscblk_cfg);
+	if (ret) {
+		DRM_ERROR("gsc: Fail to read system register\n");
+		return;
+	}
 
 	if (enable)
 		gscblk_cfg |= GSC_BLK_DISP1WB_DEST(ctx->id) |
-- 
2.17.1

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

* [PATCH] drm/exynos: gsc: Variable "gscblk_cfg" in function gsc_set_gscblk_fimd_wb() could be uninitialized
@ 2019-01-28 18:28   ` Yizhuo
  0 siblings, 0 replies; 6+ messages in thread
From: Yizhuo @ 2019-01-28 18:28 UTC (permalink / raw)
  Cc: csong, Inki Dae, linux-samsung-soc, Joonyoung Shim, David Airlie,
	Seung-Woo Kim, zhiyunq, linux-kernel, Krzysztof Kozlowski,
	Yizhuo, Kyungmin Park, Kukjin Kim, dri-devel, linux-arm-kernel

In function gsc_set_gscblk_fimd_wb(), local variable "gscblk_cfg"
could be uninitialized of function regmap_read returns -EINVAL.
However, this value will be  write to the register after "or"
operation. This is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/gpu/drm/exynos/exynos_drm_gsc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
index 0506b2b17ac1..b1d0f974fe80 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
@@ -441,11 +441,16 @@ static int gsc_sw_reset(struct gsc_context *ctx)
 static void gsc_set_gscblk_fimd_wb(struct gsc_context *ctx, bool enable)
 {
 	unsigned int gscblk_cfg;
+	int ret;
 
 	if (!ctx->sysreg)
 		return;
 
-	regmap_read(ctx->sysreg, SYSREG_GSCBLK_CFG1, &gscblk_cfg);
+	ret = regmap_read(ctx->sysreg, SYSREG_GSCBLK_CFG1, &gscblk_cfg);
+	if (ret) {
+		DRM_ERROR("gsc: Fail to read system register\n");
+		return;
+	}
 
 	if (enable)
 		gscblk_cfg |= GSC_BLK_DISP1WB_DEST(ctx->id) |
-- 
2.17.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] 6+ messages in thread

* Re: [PATCH] drm/exynos: gsc: Variable "gscblk_cfg" in function gsc_set_gscblk_fimd_wb() could be uninitialized
  2019-01-28 18:28   ` Yizhuo
  (?)
@ 2019-01-29  8:40     ` Marek Szyprowski
  -1 siblings, 0 replies; 6+ messages in thread
From: Marek Szyprowski @ 2019-01-29  8:40 UTC (permalink / raw)
  To: Yizhuo
  Cc: csong, zhiyunq, Inki Dae, Joonyoung Shim, Seung-Woo Kim,
	Kyungmin Park, David Airlie, Kukjin Kim, Krzysztof Kozlowski,
	dri-devel, linux-arm-kernel, linux-samsung-soc, linux-kernel

Hi

On 2019-01-28 19:28, Yizhuo wrote:
> In function gsc_set_gscblk_fimd_wb(), local variable "gscblk_cfg"
> could be uninitialized of function regmap_read returns -EINVAL.
> However, this value will be  write to the register after "or"
> operation. This is potentially unsafe.
>
> Signed-off-by: Yizhuo <yzhai003@ucr.edu>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_gsc.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> index 0506b2b17ac1..b1d0f974fe80 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> @@ -441,11 +441,16 @@ static int gsc_sw_reset(struct gsc_context *ctx)
>  static void gsc_set_gscblk_fimd_wb(struct gsc_context *ctx, bool enable)

This function has been completely removed in mainline kernel by commit
8b7d3ec83aba ("drm/exynos: gsc: Convert driver to IPP v2 core API"), so
there is no need for any fix anymore.

>  {
>  	unsigned int gscblk_cfg;
> +	int ret;
>  
>  	if (!ctx->sysreg)
>  		return;
>  
> -	regmap_read(ctx->sysreg, SYSREG_GSCBLK_CFG1, &gscblk_cfg);
> +	ret = regmap_read(ctx->sysreg, SYSREG_GSCBLK_CFG1, &gscblk_cfg);
> +	if (ret) {
> +		DRM_ERROR("gsc: Fail to read system register\n");
> +		return;
> +	}
>  
>  	if (enable)
>  		gscblk_cfg |= GSC_BLK_DISP1WB_DEST(ctx->id) |

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


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

* Re: [PATCH] drm/exynos: gsc: Variable "gscblk_cfg" in function gsc_set_gscblk_fimd_wb() could be uninitialized
@ 2019-01-29  8:40     ` Marek Szyprowski
  0 siblings, 0 replies; 6+ messages in thread
From: Marek Szyprowski @ 2019-01-29  8:40 UTC (permalink / raw)
  To: Yizhuo
  Cc: csong, linux-samsung-soc, David Airlie, Seung-Woo Kim, zhiyunq,
	linux-kernel, Krzysztof Kozlowski, Kyungmin Park, Kukjin Kim,
	dri-devel, linux-arm-kernel

Hi

On 2019-01-28 19:28, Yizhuo wrote:
> In function gsc_set_gscblk_fimd_wb(), local variable "gscblk_cfg"
> could be uninitialized of function regmap_read returns -EINVAL.
> However, this value will be  write to the register after "or"
> operation. This is potentially unsafe.
>
> Signed-off-by: Yizhuo <yzhai003@ucr.edu>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_gsc.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> index 0506b2b17ac1..b1d0f974fe80 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> @@ -441,11 +441,16 @@ static int gsc_sw_reset(struct gsc_context *ctx)
>  static void gsc_set_gscblk_fimd_wb(struct gsc_context *ctx, bool enable)

This function has been completely removed in mainline kernel by commit
8b7d3ec83aba ("drm/exynos: gsc: Convert driver to IPP v2 core API"), so
there is no need for any fix anymore.

>  {
>  	unsigned int gscblk_cfg;
> +	int ret;
>  
>  	if (!ctx->sysreg)
>  		return;
>  
> -	regmap_read(ctx->sysreg, SYSREG_GSCBLK_CFG1, &gscblk_cfg);
> +	ret = regmap_read(ctx->sysreg, SYSREG_GSCBLK_CFG1, &gscblk_cfg);
> +	if (ret) {
> +		DRM_ERROR("gsc: Fail to read system register\n");
> +		return;
> +	}
>  
>  	if (enable)
>  		gscblk_cfg |= GSC_BLK_DISP1WB_DEST(ctx->id) |

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm/exynos: gsc: Variable "gscblk_cfg" in function gsc_set_gscblk_fimd_wb() could be uninitialized
@ 2019-01-29  8:40     ` Marek Szyprowski
  0 siblings, 0 replies; 6+ messages in thread
From: Marek Szyprowski @ 2019-01-29  8:40 UTC (permalink / raw)
  To: Yizhuo
  Cc: csong, linux-samsung-soc, Joonyoung Shim, David Airlie,
	Seung-Woo Kim, zhiyunq, linux-kernel, Krzysztof Kozlowski,
	Inki Dae, Kyungmin Park, Kukjin Kim, dri-devel, linux-arm-kernel

Hi

On 2019-01-28 19:28, Yizhuo wrote:
> In function gsc_set_gscblk_fimd_wb(), local variable "gscblk_cfg"
> could be uninitialized of function regmap_read returns -EINVAL.
> However, this value will be  write to the register after "or"
> operation. This is potentially unsafe.
>
> Signed-off-by: Yizhuo <yzhai003@ucr.edu>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_gsc.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> index 0506b2b17ac1..b1d0f974fe80 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> @@ -441,11 +441,16 @@ static int gsc_sw_reset(struct gsc_context *ctx)
>  static void gsc_set_gscblk_fimd_wb(struct gsc_context *ctx, bool enable)

This function has been completely removed in mainline kernel by commit
8b7d3ec83aba ("drm/exynos: gsc: Convert driver to IPP v2 core API"), so
there is no need for any fix anymore.

>  {
>  	unsigned int gscblk_cfg;
> +	int ret;
>  
>  	if (!ctx->sysreg)
>  		return;
>  
> -	regmap_read(ctx->sysreg, SYSREG_GSCBLK_CFG1, &gscblk_cfg);
> +	ret = regmap_read(ctx->sysreg, SYSREG_GSCBLK_CFG1, &gscblk_cfg);
> +	if (ret) {
> +		DRM_ERROR("gsc: Fail to read system register\n");
> +		return;
> +	}
>  
>  	if (enable)
>  		gscblk_cfg |= GSC_BLK_DISP1WB_DEST(ctx->id) |

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


_______________________________________________
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] 6+ messages in thread

end of thread, other threads:[~2019-01-29  8:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20190128184257epcas2p1575d038676762164323e1946dffd1113@epcas2p1.samsung.com>
2019-01-28 18:28 ` [PATCH] drm/exynos: gsc: Variable "gscblk_cfg" in function gsc_set_gscblk_fimd_wb() could be uninitialized Yizhuo
2019-01-28 18:28   ` Yizhuo
2019-01-28 18:28   ` Yizhuo
2019-01-29  8:40   ` Marek Szyprowski
2019-01-29  8:40     ` Marek Szyprowski
2019-01-29  8:40     ` Marek Szyprowski

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.