Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4330546ybg; Mon, 8 Jun 2020 05:18:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJPlpxTTCv0GKDM2uH5w0LzJb4zXQreCXbPyuAPEZJw4/7DMmsOEnWTMm4AqOWjkURhMeR X-Received: by 2002:a05:6402:1c8b:: with SMTP id cy11mr21039982edb.122.1591618727652; Mon, 08 Jun 2020 05:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591618727; cv=none; d=google.com; s=arc-20160816; b=HXcCZqD6EnArmPNufTZWhIt06JOELyMs9ARCTEw2k/zbKd6JOAHFGhRzIBENyBXTrt WDkOxJtMPbItcDNHJ2lj9YjbsiYXFy4USYZsW8feQmc8mu2GLKq4KGLMBBppWqKtQUVh 0eJ9bypliF+i5gZ5TWIWhWPttmyIe3uytOqiQr4HU5jeX0BET5m7RH2mD8FuGwUuLzY1 HuK0j9jPDbD9ll6CsUPQSkLDyWamj/+MbU4HyoaY2Q2LQCxJkuCATzvSKnDW0BI/PGMm IyrOF6WYwceRC5R4423TrcKK6sNevSovyqyWKAwSjfRp0rp38UffDpjFjqB0EzdMGEJV gakw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=+lkkZ677rObA2JFKgW9dTrrF/B0ljp6i+KC8xv8R6Co=; b=RGnGg6x0fCDgmXtHlVd4aQjpFDzXy7SazJV8ntd1ePMhiVyM12uYsDkdt3sMr+SzuT dGa3M3j6go1i9duWFuyQS9WIGY1iAng8geuSUy+LDv6ZUmgk9ZYVMCm4Na75/4N2z9JK wPczc8s3qESxAiTY+opH1+KbBgQaDq/Wclr53lz3cD7uUvyYKPK9DgJRIAsE3FQLlShn v4NvSdOXOvR76r4h2B8hhgmS5i6sUlV2iTkmHNaVdnq/A+as+Aw9u9meZ20EC7rCQBWS xgobsbb3HSZMvbKGCEIe/pgkCOitMnze2WfxaOlSOfW524UbmZNu9foAHfj83rVN1kIv FEJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="p4/dAPrF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt17si11717389ejc.457.2020.06.08.05.18.24; Mon, 08 Jun 2020 05:18:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="p4/dAPrF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729735AbgFHMPY (ORCPT + 99 others); Mon, 8 Jun 2020 08:15:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:52722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729665AbgFHMPX (ORCPT ); Mon, 8 Jun 2020 08:15:23 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 238B7206C3; Mon, 8 Jun 2020 12:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591618522; bh=xt2dfXDYvKQ+mK/taWv4/T9nWcs8mHsbCaH3tuw/rKw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=p4/dAPrFBtt8TlGtfodkTeGQBFlrU4Gf9SF51xlpAwYPrfj9ZbmDbeHu1bP8KuHJP O0veAt7/Zab0n2v/lPigwOQ/07Kd+NaI1X6M+R7DgoUprXRYKqhMWu4bLXrfmgs0mt fNXXaDBLMdfvXYSBztqqKmPkCxjVvNiITLpF7+Mk= Date: Mon, 8 Jun 2020 14:15:19 +0200 From: Greg KH To: Matthias Brugger Cc: matthias.bgg@kernel.org, rafael@kernel.org, linux-kernel@vger.kernel.org, gene.chen.richtek@gmail.com, lee.jones@linaro.org, kernel test robot Subject: Re: [PATCH 1/2] drivers: base: Warn if driver name is not present Message-ID: <20200608121519.GA306451@kroah.com> References: <20200608095217.21162-1-matthias.bgg@kernel.org> <20200608105756.GB295073@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 08, 2020 at 01:48:28PM +0200, Matthias Brugger wrote: > > > On 08/06/2020 12:57, Greg KH wrote: > > On Mon, Jun 08, 2020 at 11:52:16AM +0200, matthias.bgg@kernel.org wrote: > >> From: Matthias Brugger > >> > >> If we pass a driver without a name, we end up in a NULL pointer > >> derefernce. > > > > That's a very good reason not to have a driver without a name :) > > > > What in-kernel driver does this? > > > >> Check for the name before trying to register the driver. > >> As we don't have a driver name to point to in the error message, we dump > >> the call stack to make it easier to detect the buggy driver. > >> > >> Reported-by: kernel test robot > >> Signed-off-by: Matthias Brugger > >> --- > >> drivers/base/driver.c | 6 ++++++ > >> 1 file changed, 6 insertions(+) > >> > >> diff --git a/drivers/base/driver.c b/drivers/base/driver.c > >> index 57c68769e157..40fba959c140 100644 > >> --- a/drivers/base/driver.c > >> +++ b/drivers/base/driver.c > >> @@ -149,6 +149,12 @@ int driver_register(struct device_driver *drv) > >> int ret; > >> struct device_driver *other; > >> > >> + if (!drv->name) { > >> + pr_err("Driver has no name.\n"); > >> + dump_stack(); > >> + return -EINVAL; > > > > Ick, no, an oops-traceback for doing something dumb like this should be > > all that we need, right? > > > > How "hardened" do we need to make internal apis anyway? What's the odds > > that if this does trigger, the driver author would even notice it? > > > > We just had the case that a driver got accepted in a maintainer repository > without a name. Which got later found by the kernel test robot. That driver had obviously never actually been run before :( > I agree with you that it probably doesn't make much sense to check for this kind > of bugs, as it should be discoverable if you test your code, before you submit. > > I propose to ignore this patch. Thanks, now dropped! greg k-h