Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3829983imu; Mon, 7 Jan 2019 10:11:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/WqKCb7DM+PCztjYJjJ3Z669Q7LtuukMpKsV+elZPWQywH9TadxsL0nF1EM+nyJblfLcUWu X-Received: by 2002:a62:11c7:: with SMTP id 68mr63556290pfr.21.1546884684583; Mon, 07 Jan 2019 10:11:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546884684; cv=none; d=google.com; s=arc-20160816; b=vRN5AOYI0WLgWDGIG+8E03F2zhm3c87qu7TCjkEsjTJHqQl/BIpWB+arGoz6ncJoW9 ndYJH9jn5eM/Sq8n33z7wrtza5PioShkDAHx6cQYf4cUKanwIBkfZ+2T0wa5WsF44ybv Xidw2YGAVrZWBV1+TfCe2MC2AqI4tBbSPcdyeUdMDPahhKHARHjZ4JhlznB5IMTTJtIz V5ssHA7gcmnGezARQkdTbetgaXdJG1EXo9N/mefU1LtumAMpOwDaPIMVLl+F980VSXI+ aalMTC6GHjpserxz88bemmFe6earAGMUsP3ppV/v/WkP8DJw1Sx1Lb3Rw74LzXNCmOHj WYrQ== 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=CG8naSudeUTQ+NjRNMwROVNjxQ7FB8sZDL2YJAe3RFg979eHELiWMJAhl6r00JEWij rrnFkXrNwPqX6qlb8/BmraEOVDuj/JFNsbUEBhIrvCTwDRkD1mx3OKREh6TVIlXZymuL 6QC/ckzueS+aceZxHzNH/PsZJxK/HeDJ6r4VV2vXNIs3LnkydclsfK/yxjYsWgVqFGy+ HIRmT3vrik2RWpeRCarhICcOGAohjA3GGhIOy8whRYrBoq1lSaEsmXqKiKRBylI6J2u3 0iIPu7dC18Jqk3lFWhmaHXI81UFu7Z57qhZjbNxMg5mTo3p/dib1PKdXOIYcD3SyA+0c i9DQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 61si13762378plz.117.2019.01.07.10.11.09; Mon, 07 Jan 2019 10:11:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1728062AbfAGRbf (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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; -- 2.19.1