From 88bcbdc681ee8b916efe231bb12c99fd32011728 Mon Sep 17 00:00:00 2001 From: fslongjin Date: Mon, 11 Jul 2022 17:22:27 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E4=BF=AE=E6=AD=A3=E4=B8=AD=E6=96=AD?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E6=97=B6=EF=BC=8C=E5=AF=B9=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=9A=84=E5=A4=84=E7=90=86=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/exception/irq.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/kernel/exception/irq.c b/kernel/exception/irq.c index b098ceae..468145c3 100644 --- a/kernel/exception/irq.c +++ b/kernel/exception/irq.c @@ -10,8 +10,7 @@ #include "../common/asm.h" #include "../common/printk.h" #include "gate.h" - - +#include // 保存函数调用现场的寄存器 #define SAVE_ALL_REGS \ @@ -166,7 +165,12 @@ int irq_register(ul irq_num, void *arg, void (*handler)(ul irq_num, ul parameter irq_desc_t *p = &interrupt_desc[irq_num - 32]; p->controller = controller; - p->irq_name = irq_name; + + int namelen = sizeof(strlen(irq_name)+1); + p->irq_name = (char *)kmalloc(namelen,0); + memset(p->irq_name, 0, namelen); + strncpy(p->irq_name, irq_name, namelen); + p->parameter = paramater; p->flags = 0; p->handler = handler; @@ -190,6 +194,7 @@ int irq_unregister(ul irq_num) p->controller->uninstall(irq_num); p->controller = NULL; + kfree(p->irq_name); p->irq_name = NULL; p->parameter = NULL; p->flags = 0; @@ -210,6 +215,5 @@ void irq_init() memset((void *)interrupt_desc, 0, sizeof(irq_desc_t) * IRQ_NUM); apic_init(); - #endif }