diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2013-11-06 03:24:02 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2013-11-08 11:10:31 -0500 |
commit | 49c2856af779bb1a36fa598804e4c0b2251fae57 (patch) | |
tree | 6293d409321ebde9c07d9eea23ffcb4c95fdcf46 /drivers/block/pktcdvd.c | |
parent | bfe11d6de1c416cea4f3f0f35f864162063ce3fa (diff) |
pktcdvd: debugfs functions return NULL on error
My static checker complains correctly that this is potential NULL
dereference because debugfs functions return NULL on error. They return
an ERR_PTR if they are configured out.
We don't need to check for ERR_PTR because if debugfs is stubbed out the
dummy functions won't complain about that. We don't need to check the
values before calling debugfs_remove() because that accepts ERR_PTRs and
NULL pointers.
We don't need to set pkt->dfs_f_info to NULL in pkt_debugfs_dev_new()
because it was initialized with kzalloc() so I have removed that.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/block/pktcdvd.c')
-rw-r--r-- | drivers/block/pktcdvd.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 56188475cfd3..ff8668c5efb1 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -473,45 +473,31 @@ static void pkt_debugfs_dev_new(struct pktcdvd_device *pd) | |||
473 | { | 473 | { |
474 | if (!pkt_debugfs_root) | 474 | if (!pkt_debugfs_root) |
475 | return; | 475 | return; |
476 | pd->dfs_f_info = NULL; | ||
477 | pd->dfs_d_root = debugfs_create_dir(pd->name, pkt_debugfs_root); | 476 | pd->dfs_d_root = debugfs_create_dir(pd->name, pkt_debugfs_root); |
478 | if (IS_ERR(pd->dfs_d_root)) { | 477 | if (!pd->dfs_d_root) |
479 | pd->dfs_d_root = NULL; | ||
480 | return; | 478 | return; |
481 | } | 479 | |
482 | pd->dfs_f_info = debugfs_create_file("info", S_IRUGO, | 480 | pd->dfs_f_info = debugfs_create_file("info", S_IRUGO, |
483 | pd->dfs_d_root, pd, &debug_fops); | 481 | pd->dfs_d_root, pd, &debug_fops); |
484 | if (IS_ERR(pd->dfs_f_info)) { | ||
485 | pd->dfs_f_info = NULL; | ||
486 | return; | ||
487 | } | ||
488 | } | 482 | } |
489 | 483 | ||
490 | static void pkt_debugfs_dev_remove(struct pktcdvd_device *pd) | 484 | static void pkt_debugfs_dev_remove(struct pktcdvd_device *pd) |
491 | { | 485 | { |
492 | if (!pkt_debugfs_root) | 486 | if (!pkt_debugfs_root) |
493 | return; | 487 | return; |
494 | if (pd->dfs_f_info) | 488 | debugfs_remove(pd->dfs_f_info); |
495 | debugfs_remove(pd->dfs_f_info); | 489 | debugfs_remove(pd->dfs_d_root); |
496 | pd->dfs_f_info = NULL; | 490 | pd->dfs_f_info = NULL; |
497 | if (pd->dfs_d_root) | ||
498 | debugfs_remove(pd->dfs_d_root); | ||
499 | pd->dfs_d_root = NULL; | 491 | pd->dfs_d_root = NULL; |
500 | } | 492 | } |
501 | 493 | ||
502 | static void pkt_debugfs_init(void) | 494 | static void pkt_debugfs_init(void) |
503 | { | 495 | { |
504 | pkt_debugfs_root = debugfs_create_dir(DRIVER_NAME, NULL); | 496 | pkt_debugfs_root = debugfs_create_dir(DRIVER_NAME, NULL); |
505 | if (IS_ERR(pkt_debugfs_root)) { | ||
506 | pkt_debugfs_root = NULL; | ||
507 | return; | ||
508 | } | ||
509 | } | 497 | } |
510 | 498 | ||
511 | static void pkt_debugfs_cleanup(void) | 499 | static void pkt_debugfs_cleanup(void) |
512 | { | 500 | { |
513 | if (!pkt_debugfs_root) | ||
514 | return; | ||
515 | debugfs_remove(pkt_debugfs_root); | 501 | debugfs_remove(pkt_debugfs_root); |
516 | pkt_debugfs_root = NULL; | 502 | pkt_debugfs_root = NULL; |
517 | } | 503 | } |