Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: ctxfi: Neaten get_daio_rsc

Move the pointer declarations into the blocks that use them.
Neaten the kfree calls when the _init functions fail.

Trivially reduces object size (defconfig x86-64)

$ size sound/pci/ctxfi/ctdaio.o.*
text data bss dec hex filename
5287 224 0 5511 1587 sound/pci/ctxfi/ctdaio.o.new
5319 224 0 5543 15a7 sound/pci/ctxfi/ctdaio.o.old

Signed-off-by: Joe Perches <joe@perches.com>
Noticed-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Joe Perches and committed by
Takashi Iwai
5395103d 103884a3

+15 -19
+15 -19
sound/pci/ctxfi/ctdaio.c
··· 528 528 struct daio **rdaio) 529 529 { 530 530 int err; 531 - struct dai *dai = NULL; 532 - struct dao *dao = NULL; 533 531 unsigned long flags; 534 532 535 533 *rdaio = NULL; ··· 542 544 return err; 543 545 } 544 546 547 + err = -ENOMEM; 545 548 /* Allocate mem for daio resource */ 546 549 if (desc->type <= DAIO_OUT_MAX) { 547 - dao = kzalloc(sizeof(*dao), GFP_KERNEL); 548 - if (!dao) { 549 - err = -ENOMEM; 550 + struct dao *dao = kzalloc(sizeof(*dao), GFP_KERNEL); 551 + if (!dao) 552 + goto error; 553 + 554 + err = dao_rsc_init(dao, desc, mgr); 555 + if (err) { 556 + kfree(dao); 550 557 goto error; 551 558 } 552 - err = dao_rsc_init(dao, desc, mgr); 553 - if (err) 554 - goto error; 555 559 556 560 *rdaio = &dao->daio; 557 561 } else { 558 - dai = kzalloc(sizeof(*dai), GFP_KERNEL); 559 - if (!dai) { 560 - err = -ENOMEM; 562 + struct dai *dai = kzalloc(sizeof(*dai), GFP_KERNEL); 563 + if (!dai) 564 + goto error; 565 + 566 + err = dai_rsc_init(dai, desc, mgr); 567 + if (err) { 568 + kfree(dai); 561 569 goto error; 562 570 } 563 - err = dai_rsc_init(dai, desc, mgr); 564 - if (err) 565 - goto error; 566 571 567 572 *rdaio = &dai->daio; 568 573 } ··· 576 575 return 0; 577 576 578 577 error: 579 - if (dao) 580 - kfree(dao); 581 - else if (dai) 582 - kfree(dai); 583 - 584 578 spin_lock_irqsave(&mgr->mgr_lock, flags); 585 579 daio_mgr_put_rsc(&mgr->mgr, desc->type); 586 580 spin_unlock_irqrestore(&mgr->mgr_lock, flags);