aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wan/pc300_tty.c
diff options
context:
space:
mode:
authorJesper Juhl <juhl-lkml@dif.dk>2005-05-03 17:33:27 -0400
committerDavid S. Miller <davem@davemloft.net>2005-05-03 17:33:27 -0400
commit6a5d362120a61a719095443194cc2d5e9a7027dd (patch)
tree7cab13ff0d252b96f4eeda7475f805ffdd1c0c4a /drivers/net/wan/pc300_tty.c
parentdb46edc6d3b66bf708a8f23a9aa89f63a49ebe33 (diff)
[WAN]: kfree of NULL pointer is valid
kfree(0) is perfectly valid, checking pointers for NULL before calling kfree() on them is redundant. The patch below cleans away a few such redundant checks (and while I was around some of those bits I couldn't stop myself from making a few tiny whitespace changes as well). Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk> Acked-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wan/pc300_tty.c')
-rw-r--r--drivers/net/wan/pc300_tty.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index 29f84ad08730..8454bf6caaa7 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -400,10 +400,8 @@ static void cpc_tty_close(struct tty_struct *tty, struct file *flip)
400 cpc_tty->buf_rx.last = NULL; 400 cpc_tty->buf_rx.last = NULL;
401 } 401 }
402 402
403 if (cpc_tty->buf_tx) { 403 kfree(cpc_tty->buf_tx);
404 kfree(cpc_tty->buf_tx); 404 cpc_tty->buf_tx = NULL;
405 cpc_tty->buf_tx = NULL;
406 }
407 405
408 CPC_TTY_DBG("%s: TTY closed\n",cpc_tty->name); 406 CPC_TTY_DBG("%s: TTY closed\n",cpc_tty->name);
409 407
@@ -666,7 +664,7 @@ static void cpc_tty_rx_work(void * data)
666 unsigned long port; 664 unsigned long port;
667 int i, j; 665 int i, j;
668 st_cpc_tty_area *cpc_tty; 666 st_cpc_tty_area *cpc_tty;
669 volatile st_cpc_rx_buf * buf; 667 volatile st_cpc_rx_buf *buf;
670 char flags=0,flg_rx=1; 668 char flags=0,flg_rx=1;
671 struct tty_ldisc *ld; 669 struct tty_ldisc *ld;
672 670
@@ -680,9 +678,9 @@ static void cpc_tty_rx_work(void * data)
680 cpc_tty = &cpc_tty_area[port]; 678 cpc_tty = &cpc_tty_area[port];
681 679
682 if ((buf=cpc_tty->buf_rx.first) != 0) { 680 if ((buf=cpc_tty->buf_rx.first) != 0) {
683 if(cpc_tty->tty) { 681 if (cpc_tty->tty) {
684 ld = tty_ldisc_ref(cpc_tty->tty); 682 ld = tty_ldisc_ref(cpc_tty->tty);
685 if(ld) { 683 if (ld) {
686 if (ld->receive_buf) { 684 if (ld->receive_buf) {
687 CPC_TTY_DBG("%s: call line disc. receive_buf\n",cpc_tty->name); 685 CPC_TTY_DBG("%s: call line disc. receive_buf\n",cpc_tty->name);
688 ld->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size); 686 ld->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size);
@@ -691,7 +689,7 @@ static void cpc_tty_rx_work(void * data)
691 } 689 }
692 } 690 }
693 cpc_tty->buf_rx.first = cpc_tty->buf_rx.first->next; 691 cpc_tty->buf_rx.first = cpc_tty->buf_rx.first->next;
694 kfree((unsigned char *)buf); 692 kfree(buf);
695 buf = cpc_tty->buf_rx.first; 693 buf = cpc_tty->buf_rx.first;
696 flg_rx = 1; 694 flg_rx = 1;
697 } 695 }
@@ -733,7 +731,7 @@ static void cpc_tty_rx_disc_frame(pc300ch_t *pc300chan)
733 731
734void cpc_tty_receive(pc300dev_t *pc300dev) 732void cpc_tty_receive(pc300dev_t *pc300dev)
735{ 733{
736 st_cpc_tty_area *cpc_tty; 734 st_cpc_tty_area *cpc_tty;
737 pc300ch_t *pc300chan = (pc300ch_t *)pc300dev->chan; 735 pc300ch_t *pc300chan = (pc300ch_t *)pc300dev->chan;
738 pc300_t *card = (pc300_t *)pc300chan->card; 736 pc300_t *card = (pc300_t *)pc300chan->card;
739 int ch = pc300chan->channel; 737 int ch = pc300chan->channel;
@@ -742,7 +740,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
742 int rx_len, rx_aux; 740 int rx_len, rx_aux;
743 volatile unsigned char status; 741 volatile unsigned char status;
744 unsigned short first_bd = pc300chan->rx_first_bd; 742 unsigned short first_bd = pc300chan->rx_first_bd;
745 st_cpc_rx_buf *new=NULL; 743 st_cpc_rx_buf *new = NULL;
746 unsigned char dsr_rx; 744 unsigned char dsr_rx;
747 745
748 if (pc300dev->cpc_tty == NULL) { 746 if (pc300dev->cpc_tty == NULL) {
@@ -762,7 +760,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
762 if (status & DST_EOM) { 760 if (status & DST_EOM) {
763 break; 761 break;
764 } 762 }
765 ptdescr=(pcsca_bd_t __iomem *)(card->hw.rambase+cpc_readl(&ptdescr->next)); 763 ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase+cpc_readl(&ptdescr->next));
766 } 764 }
767 765
768 if (!rx_len) { 766 if (!rx_len) {
@@ -771,10 +769,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
771 cpc_writel(card->hw.scabase + DRX_REG(EDAL, ch), 769 cpc_writel(card->hw.scabase + DRX_REG(EDAL, ch),
772 RX_BD_ADDR(ch, pc300chan->rx_last_bd)); 770 RX_BD_ADDR(ch, pc300chan->rx_last_bd));
773 } 771 }
774 if (new) { 772 kfree(new);
775 kfree(new);
776 new = NULL;
777 }
778 return; 773 return;
779 } 774 }
780 775
@@ -787,7 +782,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
787 continue; 782 continue;
788 } 783 }
789 784
790 new = (st_cpc_rx_buf *) kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC); 785 new = (st_cpc_rx_buf *)kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC);
791 if (new == 0) { 786 if (new == 0) {
792 cpc_tty_rx_disc_frame(pc300chan); 787 cpc_tty_rx_disc_frame(pc300chan);
793 continue; 788 continue;