From patchwork Fri Nov 23 12:01:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Mc Guire X-Patchwork-Id: 10695763 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E936F13AD for ; Fri, 23 Nov 2018 12:58:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D64C02BBD2 for ; Fri, 23 Nov 2018 12:58:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C84982BC0D; Fri, 23 Nov 2018 12:58:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 35B4E2BBD2 for ; Fri, 23 Nov 2018 12:58:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 042CE6E363; Fri, 23 Nov 2018 12:58:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 2973 seconds by postgrey-1.36 at gabe; Fri, 23 Nov 2018 12:58:36 UTC Received: from www.osadl.org (www.osadl.org [62.245.132.105]) by gabe.freedesktop.org (Postfix) with ESMTPS id C920C6E363 for ; Fri, 23 Nov 2018 12:58:36 +0000 (UTC) Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59]) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id wANC4eM0032110; Fri, 23 Nov 2018 13:04:40 +0100 From: Nicholas Mc Guire To: Tomi Valkeinen Subject: [PATCH] drm/omap: dss: do not allow devm_kasprintf() to fail Date: Fri, 23 Nov 2018 13:01:35 +0100 Message-Id: <1542974495-12387-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , linux-kernel@vger.kernel.org, Sebastian Reichel , dri-devel@lists.freedesktop.org, "Andrew F. Davis" , Peter Ujfalusi , Laurent Pinchart , Nicholas Mc Guire MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Fixes: 36c61ae2b755 ("drm/omap: dss: Remove display ordering from dss/display.c") Acked-by: Laurent Pinchart --- 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);