[PATCH] drm: check for allocation failure of kstrdup_const()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As the possible failure of the kstrdup_const(), it should
be better to check it and handle it.

Signed-off-by: Li Qiong <liqiong@xxxxxxxxxxxx>
---
 drivers/gpu/drm/drm_managed.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c
index 4cf214de50c4..d9bd4a9da559 100644
--- a/drivers/gpu/drm/drm_managed.c
+++ b/drivers/gpu/drm/drm_managed.c
@@ -151,6 +151,8 @@ int __drmm_add_action(struct drm_device *dev,
 	}
 
 	dr->node.name = kstrdup_const(name, GFP_KERNEL);
+	if (!dr->node.name)
+		return -ENOMEM;
 	if (data) {
 		void_ptr = (void **)&dr->data;
 		*void_ptr = data;
@@ -197,6 +199,8 @@ void *drmm_kmalloc(struct drm_device *dev, size_t size, gfp_t gfp)
 		return NULL;
 	}
 	dr->node.name = kstrdup_const("kmalloc", GFP_KERNEL);
+	if (!dr->node.name)
+		return NULL;
 
 	add_dr(dev, dr);
 
-- 
2.25.1




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux