From patchwork Mon Jan 7 17:31:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 154947 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3724079ljp; Mon, 7 Jan 2019 09:31:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN6okhR/1RrZz1mtbNqAEPg7QXI8GwYE5fmmbinjSW2gLHZdw26bK8ufjd2HkIeqpLVq6tvH X-Received: by 2002:a17:902:9691:: with SMTP id n17mr39815170plp.9.1546882296081; Mon, 07 Jan 2019 09:31:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546882296; cv=none; d=google.com; s=arc-20160816; b=BuC7DMsNpcbd0nJbSqU/GbgUNpUvNcGZK7AvdWNx2Gh0hxk/jpGZXboAyWlSaDhKTa JZkLnaZQNOHywwWUXSViKMDasH34rI57RHE/S1F4LC6MFLPjJpSGp6GFcXIck83QSJXU UeIqMHB4agN28IZajk9H4lN75pyzEk1pJR5y2Of6XlYA3B5M42Vwa1wZQT6k5WwKmo3v YAJQu98Cz1tggSl8eqsc2CJC55NVtXZfzSHJT+jIQODCC3zERB2rxB4bKRvlanuyXCJN t7DbivlqHihlsJeEIe0WiKCxgIlRwCN6cHIFOwh7Q6B+C0uf96fBIxX+b26M1R/SZj9M uU0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=fhWiQKGTwUaIx9qINTDmt01mL59lQ7SL6VXvKUCW3gg=; b=mW/dN9zxE2JCLRH+HtoPuuAi71rA9Xirx0x/F/wxUBr19VFr2Yk4iyZPjojYACY0M8 upI8FEAN8gkBIO4mbyMrZfB2cz1A4ggvlymoKYC3H3/kP81S+BW+yJG+lHf1pflHUlTB aKQGqEo6onMzDJmQ9+YXyxTjh+pI+V8ceqa/5X+r1WtTwGTsuJpWx7xkaeccTuJ6bs9+ 5VTXT5IelH+5AEvG4WwIj+pFK8u/IGu+hAe/WwPhw7hRWGu+PicfdS6yiKZgcwrxRbST OOuPMjl50ESAzUDIIhTU3rac5nWo02RNAzkU506CcpR4j809sWXVR447Q4zBH+bLTWMv AziQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-fbdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-fbdev-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i63si15938849pge.515.2019.01.07.09.31.35; Mon, 07 Jan 2019 09:31:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-fbdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-fbdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-fbdev-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727548AbfAGRbf (ORCPT + 1 other); Mon, 7 Jan 2019 12:31:35 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:37942 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726886AbfAGRbf (ORCPT ); Mon, 7 Jan 2019 12:31:35 -0500 Received: by mail-oi1-f193.google.com with SMTP id a77so980605oii.5; Mon, 07 Jan 2019 09:31:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fhWiQKGTwUaIx9qINTDmt01mL59lQ7SL6VXvKUCW3gg=; b=cVh68+gnAO/Xvx0j/okYIrOloGZlfFzv7qdjvQr+j402iIpvi9aqfMwp2wpX/6JhbI Nt+ClgKXRNxNoq8Pfp1QkgBrJh0c54NXlLQY8V/giVYQr+5hwPh13sRm6qioTEJQVoz4 KiXPQNeOvfShx5ZfJQoHrkTjUCHbX8hmfrb3ImjA7p5fjiB+zoM1W+iT35VpU1xSZqnL GHluUDVRMXRuFsUK+KOs0lRclZD2q7K4geNJTA27x3argmTh1IWSqavY1qsi8ID/ebJ3 yZ7IDKelSrDxGaALhUGHWERQc3jd9+PXz+fro7Cis0aHdhSwKWC8tkt/zTKt/fiiGJPV wf6A== X-Gm-Message-State: AJcUukfaLPTHjmxxPSGfpo0JRFfzTQMFiXk12I/rQNJUnRbq7U0jyOFR Qw3yV9d+NywahS67VBZWGQ== X-Received: by 2002:a54:4088:: with SMTP id i8mr40390953oii.324.1546882293833; Mon, 07 Jan 2019 09:31:33 -0800 (PST) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id o189sm32725579oif.23.2019.01.07.09.31.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 09:31:33 -0800 (PST) From: Rob Herring To: Bartlomiej Zolnierkiewicz Cc: Elimar Riesebieter , linux-kernel@vger.kernel.org, stable@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, Mathieu Malaterre Subject: [PATCH] fbdev: offb: Fix OF node name handling Date: Mon, 7 Jan 2019 11:31:32 -0600 Message-Id: <20190107173132.27316-1-robh@kernel.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Commit 5c63e407aaab ("fbdev: Convert to using %pOFn instead of device_node.name") changed how the OF FB driver handles the OF node name. This missed the case where the node name is passed to offb_init_palette_hacks(). This results in a NULL ptr dereference in strncmp and breaks any system except ones using bootx with no display node. Fix this by making offb_init_palette_hacks() use the OF node pointer and use of_node_name_prefix() helper function instead for node name comparisons. This helps in moving all OF node name accesses to helper functions in preparation to remove struct device_node.name pointer. Fixes: 5c63e407aaab ("fbdev: Convert to using %pOFn instead of device_node.name") Reported-by: Mathieu Malaterre Cc: stable@vger.kernel.org # v4.19+ Cc: Bartlomiej Zolnierkiewicz Cc: dri-devel@lists.freedesktop.org Cc: linux-fbdev@vger.kernel.org Signed-off-by: Rob Herring --- drivers/video/fbdev/offb.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 2.19.1 diff --git a/drivers/video/fbdev/offb.c b/drivers/video/fbdev/offb.c index 31f769d67195..057d3cdef92e 100644 --- a/drivers/video/fbdev/offb.c +++ b/drivers/video/fbdev/offb.c @@ -318,28 +318,28 @@ static void __iomem *offb_map_reg(struct device_node *np, int index, } static void offb_init_palette_hacks(struct fb_info *info, struct device_node *dp, - const char *name, unsigned long address) + unsigned long address) { struct offb_par *par = (struct offb_par *) info->par; - if (dp && !strncmp(name, "ATY,Rage128", 11)) { + if (of_node_name_prefix(dp, "ATY,Rage128")) { par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff); if (par->cmap_adr) par->cmap_type = cmap_r128; - } else if (dp && (!strncmp(name, "ATY,RageM3pA", 12) - || !strncmp(name, "ATY,RageM3p12A", 14))) { + } else if (of_node_name_prefix(dp, "ATY,RageM3pA") || + of_node_name_prefix(dp, "ATY,RageM3p12A")) { par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff); if (par->cmap_adr) par->cmap_type = cmap_M3A; - } else if (dp && !strncmp(name, "ATY,RageM3pB", 12)) { + } else if (of_node_name_prefix(dp, "ATY,RageM3pB")) { par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff); if (par->cmap_adr) par->cmap_type = cmap_M3B; - } else if (dp && !strncmp(name, "ATY,Rage6", 9)) { + } else if (of_node_name_prefix(dp, "ATY,Rage6")) { par->cmap_adr = offb_map_reg(dp, 1, 0, 0x1fff); if (par->cmap_adr) par->cmap_type = cmap_radeon; - } else if (!strncmp(name, "ATY,", 4)) { + } else if (of_node_name_prefix(dp, "ATY,")) { unsigned long base = address & 0xff000000UL; par->cmap_adr = ioremap(base + 0x7ff000, 0x1000) + 0xcc0; @@ -350,7 +350,7 @@ static void offb_init_palette_hacks(struct fb_info *info, struct device_node *dp par->cmap_adr = offb_map_reg(dp, 0, 0x6000, 0x1000); if (par->cmap_adr) par->cmap_type = cmap_gxt2000; - } else if (dp && !strncmp(name, "vga,Display-", 12)) { + } else if (of_node_name_prefix(dp, "vga,Display-")) { /* Look for AVIVO initialized by SLOF */ struct device_node *pciparent = of_get_parent(dp); const u32 *vid, *did; @@ -438,7 +438,7 @@ static void __init offb_init_fb(const char *name, par->cmap_type = cmap_unknown; if (depth == 8) - offb_init_palette_hacks(info, dp, name, address); + offb_init_palette_hacks(info, dp, address); else fix->visual = FB_VISUAL_TRUECOLOR;