Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4243403ybg; Mon, 8 Jun 2020 02:54:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwx4S51dTIqfaXpuTnUwBnJMlqYEBHis6yEMq/2gIvCtucCTAlVvc11enJHeehE/y7ZM88I X-Received: by 2002:a50:b2a1:: with SMTP id p30mr21823208edd.199.1591610093651; Mon, 08 Jun 2020 02:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591610093; cv=none; d=google.com; s=arc-20160816; b=pBsns5WTXvZD/K8+m2+ffv2ak4ZoMue1GibKWqTdZNkM36hfzM/MZjjW8EIUpfOGMx LcLQkodcU5Cb2Flsx1N4uo9mm6lBrTF8ZC4UG31O1b2CCk0JuRH8mn63Qs3NY0X7ff/9 +QldFMInnJDGkpaZXeQ16EgOn+KNnGssKgBWdxhVuBMTsqG8c5PgVGUK6YuFipb3OQEU uTveuy0y1eoBTM+Zejz8vVERiUYnr5nt/M9Lwtg0NAazmBPvcGblORhScEMN0/KeYlpK OJrzYQ3bRiW+C1WjUIojVoKj8xPRrOukzJfquSwklDzi8/ZnRhJzAOs2moSC+cxaYiYv x81g== 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:dkim-signature; bh=pWSnCkWAJ2GAb6uWdul4DLMh+jWMdxJdnllXJqK3bsE=; b=kcexzH6I7uvnMEAud4bVaVnQaYhIaPVG6+DNUMCeUFe88fQodPdOyV/VPlXrrMnuMJ Mx3v1VJGs1OddTKNCP3gcB448laBHNJ97T+iUPOlfVOXXdjaXckS9bKYuyRVegE+Zsus LIsPzwpqSj1342iKzC4Aconc2MVHrXMNHs/Z+A8+SGLDAwsKat9LxRqWg0CJxILRCbFg r71Eq1noUsRPcvwYc9gWtghtUnVaAWUGReeGxHZ44sMFgPeSDCRlWwQJk/H3A+lDlMx2 5xE+j7NEEDA8++pZzBHU6C5hQ+rAzgeUyuG3wu+27DkvmljpKz989bYLWypAm2HtWTsK nkPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lPWVeIjS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ob23si8866578ejb.93.2020.06.08.02.54.29; Mon, 08 Jun 2020 02:54:53 -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=lPWVeIjS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729239AbgFHJwk (ORCPT + 99 others); Mon, 8 Jun 2020 05:52:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:47744 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729166AbgFHJwk (ORCPT ); Mon, 8 Jun 2020 05:52:40 -0400 Received: from ziggy.de (unknown [213.195.114.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2449A206A4; Mon, 8 Jun 2020 09:52:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591609959; bh=hn9vi/4T2g9DMliefSxbxqUpQqK/XzJhcN2tNI0PWH8=; h=From:To:Cc:Subject:Date:From; b=lPWVeIjS6zZAiJXWqZbWVYx9NWViDjV8FwDHnGonjc0AC7zA9lsKdSnGDInRdDqHt KfETrRk+gjJktrvaLnktdcME9yHDKMrTuG6anB7qerNG3WagNn/qXLqy4pjT5Wcl7l qBp2YdrjtBIBeDcOZwK2sMbTp9FVjPTrNK2rSAm0= From: matthias.bgg@kernel.org To: gregkh@linuxfoundation.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, gene.chen.richtek@gmail.com, lee.jones@linaro.org, matthias.bgg@kernel.org, Matthias Brugger , kernel test robot Subject: [PATCH 1/2] drivers: base: Warn if driver name is not present Date: Mon, 8 Jun 2020 11:52:16 +0200 Message-Id: <20200608095217.21162-1-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.26.2 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 From: Matthias Brugger If we pass a driver without a name, we end up in a NULL pointer derefernce. 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; + } + if (!drv->bus->p) { pr_err("Driver '%s' was unable to register with bus_type '%s' because the bus was not initialized.\n", drv->name, drv->bus->name); -- 2.26.2