From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S264086AbVBDD35 (ORCPT ); Thu, 3 Feb 2005 22:29:57 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S264246AbVBDD3z (ORCPT ); Thu, 3 Feb 2005 22:29:55 -0500 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:57815 "EHLO fgwmail6.fujitsu.co.jp") by vger.kernel.org with ESMTP id S264187AbVBDD3S (ORCPT ); Thu, 3 Feb 2005 22:29:18 -0500 Date: Fri, 04 Feb 2005 12:28:36 +0900 Message-ID: <87zmyl2ecb.wl%muneda.takahiro@jp.fujitsu.com> From: MUNEDA Takahiro To: Greg KH , John Rose , Jesse Barnes Subject: [PATCH] PCI: fix pci_remove_legacy_files() crash User-Agent: Wanderlust/2.12.0 (Your Wildest Dreams) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.3 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI) Cc: muneda.takahiro@jp.fujitsu.com, LKML , linux-pci MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Hi, The legacy_io which is the member of pci_bus struct might be NULL. It should be checked. This patch checks 'b->legacy_io', NULL or not. Signed-off-by: MUNEDA Takahiro --- probe.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff -Npur a/drivers/pci/probe.c b/drivers/pci/probe.c --- a/drivers/pci/probe.c 2005-01-31 13:31:27.000000000 +0900 +++ b/drivers/pci/probe.c 2005-02-03 11:21:51.000000000 +0900 @@ -64,9 +64,11 @@ static void pci_create_legacy_files(stru void pci_remove_legacy_files(struct pci_bus *b) { - class_device_remove_bin_file(&b->class_dev, b->legacy_io); - class_device_remove_bin_file(&b->class_dev, b->legacy_mem); - kfree(b->legacy_io); /* both are allocated here */ + if (b->legacy_io) { + class_device_remove_bin_file(&b->class_dev, b->legacy_io); + class_device_remove_bin_file(&b->class_dev, b->legacy_mem); + kfree(b->legacy_io); /* both are allocated here */ + } } #else /* !HAVE_PCI_LEGACY */ static inline void pci_create_legacy_files(struct pci_bus *bus) { return; }