Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3267098pxj; Tue, 11 May 2021 00:04:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAJFpZrftIUI25AGC68lNOS6QIdttqcWQTMH7X41zrr92ElRLzI8lrrlB72FpFrRDrSd44 X-Received: by 2002:a9d:7096:: with SMTP id l22mr17571841otj.345.1620716676745; Tue, 11 May 2021 00:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620716676; cv=none; d=google.com; s=arc-20160816; b=STC+S4hqYKGoJSbz+vhoC8J9G++8SvHXVj8sJ/+RPhAaeMB6pHORczrlu9JmS89Mrf 2Mt/Bz761NyGMUtBLazKUp8QB8TZ/cLMyk4sp2GKidNJ1ZVOAPa2DHgjtepCLhNvQnEY vFr49D0tc41g1bj9oRCs/mQR4zFoZo9D8kVFQe28+ZRRMlPzuWtNu8cUz566ohSFIeg4 es1dHVP1UjDLeXHGpSCnJmBICpA2/HUhqBU1nwNkCSYfIPgCKCiRwt3zRWg56veU9ylq E16bcl54THS7yuLPjHw7F7h/sz6D+gFVOJPcuwsukSiCvlPcTLLndm1BhcoT0DAkIFhz Aqdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Rqm69kcJfmGdVqLdFvKqHCFmAg9k8OaEilR+PWHbUVY=; b=E4yWOLE7J4sI8eRYoybXx8dORnAth9SC9C+8Wy8uguYat5Q6k1YSeW0qGygRs8fluc rC2XUBHsQAPXvgjMw5PGX4Kh2VVKmGQewl+QTjh8kpLCj82C9gyyNGcv3PqgdePqDGGB A7fm9FaMjxxF1NUGhyU3B9EiVvL4gfn7fl1urpCceNUGWyPn6OpNBHxHm9Ehbu1d+4LC haQZsgCDmFagVrx+Pj/3LEAvW4EJQrAwq9nK1zdRsz4I1QQT+3TsXvMN1C92OjYOk9yB gLTzOEWeshLqGkBhq5VlfM41WXeVeklmfJT1guxel1r9xMiwKnetuVErzKCpEGs4E0CP grYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JcUBZbIM; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n14si19905015ilt.105.2021.05.11.00.04.23; Tue, 11 May 2021 00:04:36 -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=@linuxfoundation.org header.s=korg header.b=JcUBZbIM; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230129AbhEKHEm (ORCPT + 99 others); Tue, 11 May 2021 03:04:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:58396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229931AbhEKHEm (ORCPT ); Tue, 11 May 2021 03:04:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C5624616EB; Tue, 11 May 2021 07:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620716616; bh=IB3pb9y+maLrxdpuRV+w6YTrpg0ZTbK2FjvnZHsu5ig=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JcUBZbIM/WpwGCkWXs7hyDsONqSUwW+swP8CR6sOj6LoQ3o9pR1wjtuxAaN/WXVzA QJzPVvzAxiXNfHJl81Nm85lBzW+gqdiSBgJOTZQpv62+gXQpvWg5zDtkI9qtywVynn MR4b5M6czaWbOTaPCWpjU0kmQfU8DHd2yxPjG3BI= Date: Tue, 11 May 2021 09:03:34 +0200 From: Greg Kroah-Hartman To: Tong Zhang Cc: Arnd Bergmann , open list Subject: Re: [PATCH] misc: alcor_pci: fix null-ptr-deref when there is no PCI bridge Message-ID: References: <20210426220728.1230340-1-ztong0001@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 10, 2021 at 03:20:02PM -0700, Tong Zhang wrote: > On Mon, May 10, 2021 at 7:36 AM Greg Kroah-Hartman > wrote: > > > > On Mon, Apr 26, 2021 at 06:07:27PM -0400, Tong Zhang wrote: > > > the PCI bridge might be NULL, so we'd better check before use it > > > > > > [ 1.246492] BUG: kernel NULL pointer dereference, address: 00000000000000c0 > > > [ 1.248731] RIP: 0010:pci_read_config_byte+0x5/0x40 > > > [ 1.253998] Call Trace: > > > [ 1.254131] ? alcor_pci_find_cap_offset.isra.0+0x3a/0x100 [alcor_pci] > > > [ 1.254476] alcor_pci_probe+0x169/0x2d5 [alcor_pci] > > > > > > Signed-off-by: Tong Zhang > > > --- > > > drivers/misc/cardreader/alcor_pci.c | 3 +++ > > > 1 file changed, 3 insertions(+) > > > > > > diff --git a/drivers/misc/cardreader/alcor_pci.c b/drivers/misc/cardreader/alcor_pci.c > > > index cd402c89189e..1c33453fd5c7 100644 > > > --- a/drivers/misc/cardreader/alcor_pci.c > > > +++ b/drivers/misc/cardreader/alcor_pci.c > > > @@ -102,6 +102,9 @@ static int alcor_pci_find_cap_offset(struct alcor_pci_priv *priv, > > > u8 val8; > > > u32 val32; > > > > > > + if (!pci) > > > + return 0; > > > + > > > where = ALCOR_CAP_START_OFFSET; > > > pci_read_config_byte(pci, where, &val8); > > > if (!val8) > > > -- > > > 2.25.1 > > > > > > > I do not understand, how can pci ever be NULL? There is only 1 way this > > Hi Greg, > I think the problem is with > priv->parent_pdev = pdev->bus->self > where bus->self can be NULL. when bus->self is NULL, calling How can bus->self be NULL? Did you see this on a real system? How did you duplicate the error listed here? thanks, greg k-h