From patchwork Fri Aug 24 08:27:23 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: 10574911 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 5BCA4109C for ; Fri, 24 Aug 2018 08:49:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CF612BBED for ; Fri, 24 Aug 2018 08:49:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 410782BBFD; Fri, 24 Aug 2018 08:49:23 +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 BD9CB2BBED for ; Fri, 24 Aug 2018 08:49:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AF12D6E63B; Fri, 24 Aug 2018 08:49:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 1104 seconds by postgrey-1.36 at gabe; Fri, 24 Aug 2018 08:49:19 UTC Received: from www.osadl.org (www.osadl.org [62.245.132.105]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6BB696E63B for ; Fri, 24 Aug 2018 08:49:19 +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 w7O8Sl5E012215; Fri, 24 Aug 2018 10:28:47 +0200 From: Nicholas Mc Guire To: Tomi Valkeinen Subject: [PATCH RFC] drm: omapdrm: do not allow kmalloc to fail Date: Fri, 24 Aug 2018 10:27:23 +0200 Message-Id: <1535099243-29679-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 , Nicholas Mc Guire , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Andrew F Davis MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 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);