From 3d93561da888a5e334904264280f757e8452a1e1 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 26 Sep 2003 21:51:08 -0400 Subject: [PATCH] [netdrvr skge] handle proc_fs errors. Existing code does not - check if proc_fs functions return error. - use proc_mkdir to make the directory. Note pSkRootDir defined twice. --- drivers/net/sk98lin/skge.c | 67 ++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c index b891062e27694..578e4b798bc09 100644 --- a/drivers/net/sk98lin/skge.c +++ b/drivers/net/sk98lin/skge.c @@ -607,12 +607,6 @@ static uintptr_t TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}}; static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480}; -#ifdef CONFIG_PROC_FS -static struct proc_dir_entry *pSkRootDir; -#endif - - - /***************************************************************************** * * skge_probe - find all SK-98xx adapters @@ -638,7 +632,6 @@ static int __init skge_probe (void) SK_BOOL BootStringCount = SK_FALSE; int retval; #ifdef CONFIG_PROC_FS - int proc_root_initialized = 0; struct proc_dir_entry *pProcFile; #endif @@ -758,26 +751,28 @@ static int __init skge_probe (void) sizeof(SK_Root_Dir_entry) - 1); /*Create proc (directory)*/ - if(!proc_root_initialized) { - pSkRootDir = create_proc_entry(SK_Root_Dir_entry, - S_IFDIR | S_IWUSR | S_IRUGO | S_IXUGO, proc_net); - pSkRootDir->owner = THIS_MODULE; - proc_root_initialized = 1; + if(!pSkRootDir) { + pSkRootDir = proc_mkdir(SK_Root_Dir_entry, proc_net); + if (!pSkRootDir) + printk(KERN_WARNING "%s: Unable to create /proc/net/%s", + dev->name, SK_Root_Dir_entry); + else + pSkRootDir->owner = THIS_MODULE; } } - - /* Create proc file */ - pProcFile = create_proc_entry(dev->name, - S_IFREG | S_IXUSR | S_IWGRP | S_IROTH, - pSkRootDir); - - pProcFile->read_proc = sk_proc_read; - pProcFile->write_proc = NULL; - pProcFile->nlink = 1; - pProcFile->size = sizeof(dev->name + 1); - pProcFile->data = (void *)pProcFile; - pProcFile->owner = THIS_MODULE; + /* Create proc file */ + if (pSkRootDir && + (pProcFile = create_proc_entry(dev->name, + S_IFREG | S_IXUSR | S_IWGRP | S_IROTH, + pSkRootDir))) { + pProcFile->read_proc = sk_proc_read; + pProcFile->write_proc = NULL; + pProcFile->nlink = 1; + pProcFile->size = sizeof(dev->name + 1); + pProcFile->data = (void *)pProcFile; + pProcFile->owner = THIS_MODULE; + } #endif pNet->PortNr = 0; @@ -831,17 +826,18 @@ static int __init skge_probe (void) #endif #ifdef CONFIG_PROC_FS - pProcFile = create_proc_entry(dev->name, - S_IFREG | S_IXUSR | S_IWGRP | S_IROTH, - pSkRootDir); - + if (pSkRootDir + && (pProcFile = create_proc_entry(dev->name, + S_IFREG | S_IXUSR | S_IWGRP | S_IROTH, + pSkRootDir))) { - pProcFile->read_proc = sk_proc_read; - pProcFile->write_proc = NULL; - pProcFile->nlink = 1; - pProcFile->size = sizeof(dev->name + 1); - pProcFile->data = (void *)pProcFile; - pProcFile->owner = THIS_MODULE; + pProcFile->read_proc = sk_proc_read; + pProcFile->write_proc = NULL; + pProcFile->nlink = 1; + pProcFile->size = sizeof(dev->name + 1); + pProcFile->data = (void *)pProcFile; + pProcFile->owner = THIS_MODULE; + } #endif memcpy((caddr_t) &dev->dev_addr, @@ -1188,7 +1184,8 @@ SK_EVPARA EvPara; #ifdef CONFIG_PROC_FS /* clear proc-dir */ - remove_proc_entry(pSkRootDir->name, proc_net); + if (pSkRootDir) + remove_proc_entry(pSkRootDir->name, proc_net); #endif } /* skge_cleanup_module */ -- 2.53.0