[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1542974495-12387-1-git-send-email-hofrat@osadl.org>
Date: Fri, 23 Nov 2018 13:01:35 +0100
From: Nicholas Mc Guire <hofrat@...dl.org>
To: Tomi Valkeinen <tomi.valkeinen@...com>
Cc: David Airlie <airlied@...ux.ie>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Sebastian Reichel <sre@...nel.org>,
Peter Ujfalusi <peter.ujfalusi@...com>,
"Andrew F. Davis" <afd@...com>, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, Nicholas Mc Guire <hofrat@...dl.org>
Subject: [PATCH] drm/omap: dss: do not allow devm_kasprintf() to fail
omapdss_display_init() is called by multiple drivers and does not expect
a return value so without changing all call-sites the low-probability
failure of devm_kasprintf() can not be reported up the call stack. As
the amount allocated here is very small (<= 16 bytes) and it is an
initialization function that most likely will be called during system
initialization it should be OK to use __GFP_NOFAIL here to prevent
devm_kasprintf() from returning NULL.
Signed-off-by: Nicholas Mc Guire <hofrat@...dl.org>
Fixes: 36c61ae2b755 ("drm/omap: dss: Remove display ordering from dss/display.c")
---
Problem located with experimental coccinelle script
While the use of __GFP_NOFAIL is to be limited (small infrequent
allocations) this case does seems suitable as it is rare and small
(initialization) .As all the current drivers using
omapdss_display_init() currently seem not to initialize dssdev->name
prior to calling omapdss_display_init() and the unlikely failure
case can not be reasonably responded (returns void) not allowing
a allocation failure here should be acceptable.
Patch was compile tested with: omap2plus_defconfig (implies OMAP_DSS_BASE=m)
Patch is against 4.20-rc3 (localversion-next is next-20181123)
drivers/gpu/drm/omapdrm/dss/display.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c
index 34b2a4e..7dbe874 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -45,7 +45,8 @@ void omapdss_display_init(struct omap_dss_device *dssdev)
of_property_read_string(dssdev->dev->of_node, "label", &dssdev->name);
if (dssdev->name == NULL)
- dssdev->name = devm_kasprintf(dssdev->dev, GFP_KERNEL,
+ dssdev->name = devm_kasprintf(dssdev->dev,
+ GFP_KERNEL | __GFP_NOFAIL,
"display%u", id);
}
EXPORT_SYMBOL_GPL(omapdss_display_init);
--
2.1.4
Powered by blists - more mailing lists