Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3983941imu; Mon, 7 Jan 2019 13:11:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/VEdw7FyNKIlVeQVL9QHYGtWJKnTTA8hS+PauG26HX3oRf5TZCUaU722gr/27mhpQQ1URUF X-Received: by 2002:a62:2f06:: with SMTP id v6mr65317841pfv.216.1546895463976; Mon, 07 Jan 2019 13:11:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546895463; cv=none; d=google.com; s=arc-20160816; b=sRi32wt91WDFIOVnWTUS8hGh9CTOopxjImUszBCYrOZ2BDOILoxVzzWyZPdrtUKiU2 oRwCcViWNHUyO14cWgfHUNvlPzLSziHzHmVxyYWaTOVyyhxlUPvCapcsjp4hNOXFkGLP ewc9IqNWoXO1/uYG2jrUEuNeQdgpTZ2AtFfR1guBsnxyTeBvHi0rGK8O2aPeOXZYjOy6 NdAXAWfA9KX+1nDsBpjPXZvN/QmSHqTZOkp47HFaRO74U0NGiSq2UwrpCMsQm+Q/pGbs W3z7UsiAwv/9cWG+qQPpjsSy2VGYJK7TPQr0woaKpBC1H4wst/eVazIt/If9cxpD7hO1 GCFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=+jwwNXK1Y88yrzPydfDKP0Tb8tQ0ZIKdHk/HF4vjcHY=; b=J3pBdw3VIxhlj571umnEfGa9lsPYJNRtI7M/xZtMSvGnqBBuvwJCWRpeNNmtggIJ83 GXpcMsKcYdTmf02XnjM0WXyiVOLd+0zXnBtW9DsGG4bx2I7RAHr26YL8go67a0YGAKO2 woY3ja6EDHGqAf36iy9FSSpcNkGFDqYD6ehBgX6jmyc/VCynvDNUQ3wRIiZMJ1xKapDP h2in64dEsTl7pzjjNNGd3c9VYLcIK+IaFX08nb4MFLv2amjutWFjeTHxl77fH3nhy+Aj WjokKtMo6cVRShhsNH45+J4ADaEOlrioeaNiE6c9q7xWpBzd2MWd75ZkqUjOGsItFrp1 uRpQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si4142544pfn.285.2019.01.07.13.10.46; Mon, 07 Jan 2019 13:11:03 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726874AbfAGUgj (ORCPT + 99 others); Mon, 7 Jan 2019 15:36:39 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:38846 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbfAGUgj (ORCPT ); Mon, 7 Jan 2019 15:36:39 -0500 Received: by mail-ot1-f67.google.com with SMTP id e12so1551378otl.5; Mon, 07 Jan 2019 12:36:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+jwwNXK1Y88yrzPydfDKP0Tb8tQ0ZIKdHk/HF4vjcHY=; b=UTcxIzTE5Lb+nfO3thGtDYkEig/ZCOGkyvVTGDU77KVnPz3SowEtjt0sKmxmW7Mvwz hKbbfwot0p+JL2EFVxw/Z6Tp+hu+jx/6GS9KzmPE8OtEwryoDExVwSfORbE7FszdIG+F pcBBeyE65Uw0sjnZ5FrGSjxXjZUTqdy8hxw7iG0GaEoIRSiEXWCklc2N10MBiT2kOVoF igRo968MQ08kbVEGlYa78kf2jc59ynZI/b75Bf5CIU9O9+QNsirwIAIVtdHX0jAuf8EV 1EuqzCY2lGu+vInI6MmW9T4zcSkEeTM+JpPpGLMv5yRBpAQGa8/jtoi4gMb1G2MN5wLF crXw== X-Gm-Message-State: AJcUukcqHG9dpgU8lWv1EyiBAZSWlsPjeF/25YCHrFNznVgsw3iT5trw 7ZIXlhBoBgHrLqRPeKVcJSPzib/HMsNBeYnW/ih70TEk X-Received: by 2002:a9d:628:: with SMTP id 37mr44348033otn.58.1546893398089; Mon, 07 Jan 2019 12:36:38 -0800 (PST) MIME-Version: 1.0 References: <20190107173132.27316-1-robh@kernel.org> In-Reply-To: From: Mathieu Malaterre Date: Mon, 7 Jan 2019 21:36:26 +0100 Message-ID: Subject: Re: [PATCH] fbdev: offb: Fix OF node name handling To: Rob Herring Cc: Bartlomiej Zolnierkiewicz , Elimar Riesebieter , LKML , "# v4 . 11" , dri-devel , Linux Fbdev development list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rob, On Mon, Jan 7, 2019 at 9:11 PM Mathieu Malaterre wrote: > > On Mon, Jan 7, 2019 at 6:31 PM Rob Herring wrote: > > > > 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") > > Looks good to me: > > ... > [ 0.000000] Linux version 5.0.0-rc1+ (malat@debian.org) (gcc > version 6.3.0 20170516 (Debian 6.3.0-18)) #21 Mon Jan 7 21:03:53 CET > 2019 > ... > > So here is my : > > Tested-by: Mathieu Malaterre Just for curiosity, why would you keep: if (strcmp(dp->name, "valkyrie") == 0) > > 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 > >