Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752199AbcLDF2c (ORCPT ); Sun, 4 Dec 2016 00:28:32 -0500 Received: from m50-132.163.com ([123.125.50.132]:34196 "EHLO m50-132.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750748AbcLDF2a (ORCPT ); Sun, 4 Dec 2016 00:28:30 -0500 From: Pan Bian To: Samuel Ortiz , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] net: irda: set error code on failures Date: Sun, 4 Dec 2016 13:27:40 +0800 Message-Id: <1480829260-4590-1-git-send-email-bianpan201603@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DNGowADXTttMqUNYK1KqIQ--.16807S3 X-Coremail-Antispam: 1Uf129KBjvdXoWruw15AFWUXw4UKF1rtFW7CFg_yoWftwcEga y8XF4xJr1rJr40qw1UCrWxZr93tFnrWw1xuryfK343tryjy3WrAws7XF98Xr4xW397uF95 Cas0qFy8u34DXjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUYkl1PUUUUU== X-Originating-IP: [114.243.30.33] X-CM-SenderInfo: held01tdqsiiqwqtqiywtou0bp/xtbBbA4291c68aFUjgAAsE Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 923 Lines: 28 From: Pan Bian When the calls to kzalloc() fail, the value of return variable ret may be 0. 0 means success in this context. This patch fixes the bug, assigning "-ENOMEM" to ret before calling kzalloc(). Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188971 Signed-off-by: Pan Bian --- drivers/net/irda/irda-usb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c index a198946..8716b8c 100644 --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c @@ -1723,6 +1723,7 @@ static int irda_usb_probe(struct usb_interface *intf, /* Don't change this buffer size and allocation without doing * some heavy and complete testing. Don't ask why :-( * Jean II */ + ret = -ENOMEM; self->speed_buff = kzalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL); if (!self->speed_buff) goto err_out_3; -- 1.9.1