From 88e7bf2a4c35d1200c2f72f5cd3d9e72c7f6c890 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Sat, 27 Jan 2007 13:52:52 +0100 Subject: ieee1394: dv1394: fix CardBus card ejection Fix NULL pointer dereference on hot ejection of a FireWire card while dv1394 was loaded. http://bugzilla.kernel.org/show_bug.cgi?id=7121 I did not test card ejection with open /dev/dv1394 files yet. Signed-off-by: Stefan Richter --- drivers/ieee1394/dv1394.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'drivers/ieee1394/dv1394.c') diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c index 1084da4d88a..d636cfad7fc 100644 --- a/drivers/ieee1394/dv1394.c +++ b/drivers/ieee1394/dv1394.c @@ -2267,11 +2267,7 @@ static void dv1394_remove_host (struct hpsb_host *host) { struct video_card *video; unsigned long flags; - int id = host->id; - - /* We only work with the OHCI-1394 driver */ - if (strcmp(host->driver->name, OHCI1394_DRIVER_NAME)) - return; + int id = host->id, found_ohci_card = 0; /* find the corresponding video_cards */ do { @@ -2284,6 +2280,7 @@ static void dv1394_remove_host (struct hpsb_host *host) if ((tmp_vid->id >> 2) == id) { list_del(&tmp_vid->list); video = tmp_vid; + found_ohci_card = 1; break; } } @@ -2293,8 +2290,9 @@ static void dv1394_remove_host (struct hpsb_host *host) dv1394_un_init(video); } while (video != NULL); - class_device_destroy(hpsb_protocol_class, - MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2))); + if (found_ohci_card) + class_device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR, + IEEE1394_MINOR_BLOCK_DV1394 * 16 + (host->id << 2))); } static void dv1394_add_host (struct hpsb_host *host) -- cgit v1.2.3 From 12ba145c9406da72c8288245f352de7f37188f1f Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Sat, 27 Jan 2007 13:54:23 +0100 Subject: ieee1394: dv1394: tidy up card removal small coding style touch-up and terser coding Signed-off-by: Stefan Richter --- drivers/ieee1394/dv1394.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'drivers/ieee1394/dv1394.c') diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c index d636cfad7fc..55d6ae664fd 100644 --- a/drivers/ieee1394/dv1394.c +++ b/drivers/ieee1394/dv1394.c @@ -2255,47 +2255,37 @@ static int dv1394_init(struct ti_ohci *ohci, enum pal_or_ntsc format, enum modes return 0; } -static void dv1394_un_init(struct video_card *video) +static void dv1394_remove_host(struct hpsb_host *host) { - /* obviously nobody has the driver open at this point */ - do_dv1394_shutdown(video, 1); - kfree(video); -} - - -static void dv1394_remove_host (struct hpsb_host *host) -{ - struct video_card *video; + struct video_card *video, *tmp_video; unsigned long flags; - int id = host->id, found_ohci_card = 0; + int found_ohci_card = 0; - /* find the corresponding video_cards */ do { - struct video_card *tmp_vid; - video = NULL; - spin_lock_irqsave(&dv1394_cards_lock, flags); - list_for_each_entry(tmp_vid, &dv1394_cards, list) { - if ((tmp_vid->id >> 2) == id) { - list_del(&tmp_vid->list); - video = tmp_vid; + list_for_each_entry(tmp_video, &dv1394_cards, list) { + if ((tmp_video->id >> 2) == host->id) { + list_del(&tmp_video->list); + video = tmp_video; found_ohci_card = 1; break; } } spin_unlock_irqrestore(&dv1394_cards_lock, flags); - if (video) - dv1394_un_init(video); - } while (video != NULL); + if (video) { + do_dv1394_shutdown(video, 1); + kfree(video); + } + } while (video); if (found_ohci_card) class_device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (host->id << 2))); } -static void dv1394_add_host (struct hpsb_host *host) +static void dv1394_add_host(struct hpsb_host *host) { struct ti_ohci *ohci; int id = host->id; -- cgit v1.2.3 From 2b8693c0617e972fc0b2fd1ebf8de97e15b656c3 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Mon, 12 Feb 2007 00:55:32 -0800 Subject: [PATCH] mark struct file_operations const 3 Many struct file_operations in the kernel can be "const". Marking them const moves these to the .rodata section, which avoids false sharing with potential dirty data. In addition it'll catch accidental writes at compile time to these shared resources. Signed-off-by: Arjan van de Ven Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ieee1394/dv1394.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/ieee1394/dv1394.c') diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c index 55d6ae664fd..dee9529aa8e 100644 --- a/drivers/ieee1394/dv1394.c +++ b/drivers/ieee1394/dv1394.c @@ -2147,7 +2147,7 @@ out: } static struct cdev dv1394_cdev; -static struct file_operations dv1394_fops= +static const struct file_operations dv1394_fops= { .owner = THIS_MODULE, .poll = dv1394_poll, -- cgit v1.2.3