Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751804AbcLCLZB (ORCPT ); Sat, 3 Dec 2016 06:25:01 -0500 Received: from m50-132.163.com ([123.125.50.132]:59600 "EHLO m50-132.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbcLCLY7 (ORCPT ); Sat, 3 Dec 2016 06:24:59 -0500 From: Pan Bian To: Woojung Huh , Microchip Linux Driver Support , netdev@vger.kernel.org, linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] net: usb: set error code when usb_alloc_urb fails Date: Sat, 3 Dec 2016 19:24:48 +0800 Message-Id: <1480764288-5448-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DNGowACnp+6Aq0JY6V4SIQ--.19731S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrtw45Cr1ruw13WF43GFyfZwb_yoWfurb_uw 18W3Zruw1xZrWUW3WxKw4SvFySk34UXwn7Wrnag39I9r1jy3ZIv3Z7uFZ7Zw17Wrs7Cayq kwnYqw15C3srGjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUeN_-PUUUUU== X-Originating-IP: [222.131.246.88] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBzwI1claDscdeNAAAsD Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 907 Lines: 28 In function lan78xx_probe(), variable ret takes the errno code on failures. However, when the call to usb_alloc_urb() fails, its value will keeps 0. 0 indicates success in the context, which is inconsistent with the execution result. This patch fixes the bug, assigning "-ENOMEM" to ret when usb_alloc_urb() returns a NULL pointer. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188771 Signed-off-by: Pan Bian --- drivers/net/usb/lan78xx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index db558b8..f33460c 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3395,6 +3395,7 @@ static int lan78xx_probe(struct usb_interface *intf, if (buf) { dev->urb_intr = usb_alloc_urb(0, GFP_KERNEL); if (!dev->urb_intr) { + ret = -ENOMEM; kfree(buf); goto out3; } else { -- 1.9.1