linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/imx: imx-ldb: Check for null pointer after calling kmemdup
@ 2022-01-05  7:47 Jiasheng Jiang
  2022-03-29 16:41 ` Philipp Zabel
  0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2022-01-05  7:47 UTC (permalink / raw)
  To: p.zabel, airlied, daniel, shawnguo, s.hauer, kernel, festevam, linux-imx
  Cc: dri-devel, linux-arm-kernel, linux-kernel, Jiasheng Jiang

As the possible failure of the allocation, kmemdup() may return NULL
pointer.
Therefore, it should be better to check the return value of kmemdup()
and return error if fails.

Fixes: dc80d7038883 ("drm/imx-ldb: Add support to drm-bridge")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/gpu/drm/imx/imx-ldb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index 53132ddf9587..f9880a779678 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -574,6 +574,8 @@ static int imx_ldb_panel_ddc(struct device *dev,
 		edidp = of_get_property(child, "edid", &edid_len);
 		if (edidp) {
 			channel->edid = kmemdup(edidp, edid_len, GFP_KERNEL);
+			if (!channel->edid)
+				return -ENOMEM;
 		} else if (!channel->panel) {
 			/* fallback to display-timings node */
 			ret = of_get_drm_display_mode(child,
-- 
2.25.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] 2+ messages in thread

* Re: [PATCH] drm/imx: imx-ldb: Check for null pointer after calling kmemdup
  2022-01-05  7:47 [PATCH] drm/imx: imx-ldb: Check for null pointer after calling kmemdup Jiasheng Jiang
@ 2022-03-29 16:41 ` Philipp Zabel
  0 siblings, 0 replies; 2+ messages in thread
From: Philipp Zabel @ 2022-03-29 16:41 UTC (permalink / raw)
  To: Jiasheng Jiang, airlied, daniel, shawnguo, s.hauer, kernel,
	festevam, linux-imx
  Cc: dri-devel, linux-arm-kernel, linux-kernel

On Mi, 2022-01-05 at 15:47 +0800, Jiasheng Jiang wrote:
> As the possible failure of the allocation, kmemdup() may return NULL
> pointer.
> Therefore, it should be better to check the return value of kmemdup()
> and return error if fails.
> 
> Fixes: dc80d7038883 ("drm/imx-ldb: Add support to drm-bridge")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  drivers/gpu/drm/imx/imx-ldb.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-
> ldb.c
> index 53132ddf9587..f9880a779678 100644
> --- a/drivers/gpu/drm/imx/imx-ldb.c
> +++ b/drivers/gpu/drm/imx/imx-ldb.c
> @@ -574,6 +574,8 @@ static int imx_ldb_panel_ddc(struct device *dev,
>                 edidp = of_get_property(child, "edid", &edid_len);
>                 if (edidp) {
>                         channel->edid = kmemdup(edidp, edid_len,
> GFP_KERNEL);
> +                       if (!channel->edid)
> +                               return -ENOMEM;
>                 } else if (!channel->panel) {
>                         /* fallback to display-timings node */
>                         ret = of_get_drm_display_mode(child,

Thank you, applied to imx-drm/fixes.

regards
Philipp
_______________________________________________
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] 2+ messages in thread

end of thread, other threads:[~2022-03-29 16:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05  7:47 [PATCH] drm/imx: imx-ldb: Check for null pointer after calling kmemdup Jiasheng Jiang
2022-03-29 16:41 ` Philipp Zabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).