From 08710da3cf932149de3440bbaec4dfdfba5a33df Mon Sep 17 00:00:00 2001 From: Meghana Madhyastha Date: Sat, 16 Sep 2017 10:34:05 +0530 Subject: Staging: speakup: Remove print following unsuccessful kmalloc Remove print statement following unsuccessful kmalloc when there is not enough memory. Kmalloc and variants normally produce a backtrace in such a case. Hence, a print statement is not necessary. Found using the following Coccinelle semantic patch: @@ identifier i; @@ i = (\(kmalloc\|devm_kzalloc\|kmalloc_array\| devm_ioremap\|usb_alloc_urb\|alloc_netdev\|dev_alloc_skb\| kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...)); ( if (i == NULL) { -\(DBG_8723A\|printk\|pr_err\|CERROR\|DBG_88E\)(...); ...when any } | if (!i) { -\(DBG_8723A\|printk\|pr_err\|CERROR\|DBG_88E\)(...); ...when any } ) @@ identifier i; @@ ( - if (i == NULL) { + if (i == NULL) return ...; - } | - if (!i) { + if (!i) return ...; - } ) Signed-off-by: Meghana Madhyastha Acked-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/spk_ttyio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging/speakup') diff --git a/drivers/staging/speakup/spk_ttyio.c b/drivers/staging/speakup/spk_ttyio.c index 4d7d8f2f66ea..a6330e2cb162 100644 --- a/drivers/staging/speakup/spk_ttyio.c +++ b/drivers/staging/speakup/spk_ttyio.c @@ -51,10 +51,8 @@ static int spk_ttyio_ldisc_open(struct tty_struct *tty) speakup_tty = tty; ldisc_data = kmalloc(sizeof(struct spk_ldisc_data), GFP_KERNEL); - if (!ldisc_data) { - pr_err("speakup: Failed to allocate ldisc_data.\n"); + if (!ldisc_data) return -ENOMEM; - } sema_init(&ldisc_data->sem, 0); ldisc_data->buf_free = true; -- cgit v1.2.3