* [PATCH RFC] drm: omapdrm: do not allow kmalloc to fail
@ 2018-08-24 8:27 Nicholas Mc Guire
0 siblings, 0 replies; only message in thread
From: Nicholas Mc Guire @ 2018-08-24 8:27 UTC (permalink / raw)
To: Tomi Valkeinen
Cc: David Airlie, Andrew F Davis, dri-devel, linux-kernel, Nicholas Mc Guire
As this is during init this allocation should not fail and given that the
code is in this state now for 4 years+ this seems to have worked.
kmalloc should be checked though or forced not to fail - Not really sure
but this case seems suitable for __GFP_NOFAIL (relatively small
allocation early in the boot process where it should not fail). The
alternative would probably be a BUG_ON(!new_compat); here.
Issue was introduced by
commit f2dd36ac9974 ("OMAPDSS: move 'compatible' converter to omapdss driver")
and there is the identical issue in:
./drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c:113:
Pleas let me know if that fix (use of __GFP_NOFAIL) is suitable for this
situation.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: f2dd36ac9974 ("OMAPDSS: move 'compatible' converter to omapdss driver")
---
Issue located with an experimental coccinelle script
Patch was compile tested with: omap2plus_defconfig (implies OMAP2_DSS_INIT=y)
Patch is against 4.18 (localversion-next is next-20180824)
drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
index 3bfb95d..1e07c07 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
@@ -110,7 +110,7 @@ static void __init omapdss_omapify_node(struct device_node *node)
num_strs = omapdss_count_strings(prop);
new_len = prop->length + strlen(prefix) * num_strs;
- new_compat = kmalloc(new_len, GFP_KERNEL);
+ new_compat = kmalloc(new_len, GFP_KERNEL | __GFP_NOFAIL);
omapdss_prefix_strcpy(new_compat, new_len, prop->value, prop->length);
--
2.1.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-08-24 8:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-24 8:27 [PATCH RFC] drm: omapdrm: do not allow kmalloc to fail Nicholas Mc Guire
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).