aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Lynch <ntl@pobox.com>2008-03-23 18:51:45 -0400
committerPaul Mackerras <paulus@samba.org>2008-03-25 17:44:07 -0400
commitf61fb8a52cdf8b9b6a6badde84aefe58cb35d315 (patch)
treeb41a13d09c471b97c77d686fb600435a7906145e
parent9356d90effa39c83c8fdba2a14cecec79959d4d0 (diff)
[POWERPC] scanlog_init cleanup and minor fixes
scanlog_init() could use some love. * properly return -ENODEV if this system doesn't support scan-log-dump * don't printk if scan-log-dump not present; only older systems have it * convert from create_proc_entry() to preferred proc_create() * allocate zeroed data buffer * fix potential memory leak of ent->data on failed create_proc_entry() * simplify control flow Signed-off-by: Nathan Lynch <ntl@pobox.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r--arch/powerpc/platforms/pseries/scanlog.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/arch/powerpc/platforms/pseries/scanlog.c b/arch/powerpc/platforms/pseries/scanlog.c
index 8e1ef168e2dd..e5b0ea870164 100644
--- a/arch/powerpc/platforms/pseries/scanlog.c
+++ b/arch/powerpc/platforms/pseries/scanlog.c
@@ -195,31 +195,30 @@ const struct file_operations scanlog_fops = {
195static int __init scanlog_init(void) 195static int __init scanlog_init(void)
196{ 196{
197 struct proc_dir_entry *ent; 197 struct proc_dir_entry *ent;
198 void *data;
199 int err = -ENOMEM;
198 200
199 ibm_scan_log_dump = rtas_token("ibm,scan-log-dump"); 201 ibm_scan_log_dump = rtas_token("ibm,scan-log-dump");
200 if (ibm_scan_log_dump == RTAS_UNKNOWN_SERVICE) { 202 if (ibm_scan_log_dump == RTAS_UNKNOWN_SERVICE)
201 printk(KERN_ERR "scan-log-dump not implemented on this system\n"); 203 return -ENODEV;
202 return -EIO;
203 }
204 204
205 ent = create_proc_entry("ppc64/rtas/scan-log-dump", S_IRUSR, NULL); 205 /* Ideally we could allocate a buffer < 4G */
206 if (ent) { 206 data = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL);
207 ent->proc_fops = &scanlog_fops; 207 if (!data)
208 /* Ideally we could allocate a buffer < 4G */ 208 goto err;
209 ent->data = kmalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL); 209
210 if (!ent->data) { 210 ent = proc_create("ppc64/rtas/scan-log-dump", S_IRUSR, NULL,
211 printk(KERN_ERR "Failed to allocate a buffer\n"); 211 &scanlog_fops);
212 remove_proc_entry("scan-log-dump", ent->parent); 212 if (!ent)
213 return -ENOMEM; 213 goto err;
214 } 214
215 ((unsigned int *)ent->data)[0] = 0; 215 ent->data = data;
216 } else {
217 printk(KERN_ERR "Failed to create ppc64/scan-log-dump proc entry\n");
218 return -EIO;
219 }
220 proc_ppc64_scan_log_dump = ent; 216 proc_ppc64_scan_log_dump = ent;
221 217
222 return 0; 218 return 0;
219err:
220 kfree(data);
221 return err;
223} 222}
224 223
225static void __exit scanlog_cleanup(void) 224static void __exit scanlog_cleanup(void)