Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3785525imm; Mon, 11 Jun 2018 01:33:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLBDNFHOsYiAC5njgve7AoK8n1tRrSSF8xOO8Gk5Ro9M8Y/O9BCEb++BCAMnFPNp0w5n8P/ X-Received: by 2002:a17:902:6b84:: with SMTP id p4-v6mr17428662plk.272.1528705987592; Mon, 11 Jun 2018 01:33:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528705987; cv=none; d=google.com; s=arc-20160816; b=Syby0u1fhGonpDm6YcHppQ3J9nwVVCffN3uOSR1pVDNgUInHC0yd6JUwqdEQv0e1sI KRv537exzQbVN+GgSbS3zDj5MylVgDrEDANa34qbnCPbC2mYuF97DWZuuhYYM0z/Tr1h 0CcULP9iyuICfP5lmaDGR88doAdLdkzubQ9+LosZLFMG4ue8FP9IAYs9bMvvqjnJg7JL U+BHLpY4DTaNbXdFifQ6LM4+ShBndyVnKn14JiG9dIw2h4gOuGWd3R56DDDCRGH9/zA1 l/Vba78Vb2iz7M3hMXRzm4sz+2X4IH3lgC5doilEMp6delJglXWUj0wkLmNDfyZ29xd0 lzoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature:arc-authentication-results; bh=DZn0cvxZYBKzPVqxEZkVRGav/8WAngKpc5Ezz31M+PM=; b=X7RQKpwyWZndZ3t0Q0+QL/OQlCXjTEhJknUi7B31i0COvw2Mx/WPc7zZkT8BXL2Wwh phAAFF40wuH3XSFnHnQ+Zp3whdQbw25HziD14JF+RPbPPQ2862cCh/lc2IlDhB61lBnf 5nJc1zILnpg07sIOE82N9eDER0emGsO6N5/7LT9W9eX8x09f29J/TLnevcg7V5Kw3tDg 7HcBCz4f/rd12eWViMCnqoeBfLqhx2aNqTHvycZI9d0u685E25WmxH+d4JHqBe2X/CMx c31cXMOyq5SYP4ZpiVqEtQDpxpUm452SJ4ww48oJ2BY1dG96Z6eA+Eki9B+NjJ9ZeUxG mt9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=HZ7MemIc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p16-v6si17267791pgc.204.2018.06.11.01.32.53; Mon, 11 Jun 2018 01:33:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=HZ7MemIc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754172AbeFKIb0 (ORCPT + 99 others); Mon, 11 Jun 2018 04:31:26 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33194 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754010AbeFKIbZ (ORCPT ); Mon, 11 Jun 2018 04:31:25 -0400 Received: by mail-pf0-f196.google.com with SMTP id b17-v6so9844677pfi.0 for ; Mon, 11 Jun 2018 01:31:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=DZn0cvxZYBKzPVqxEZkVRGav/8WAngKpc5Ezz31M+PM=; b=HZ7MemIcIx29yjJcnCrRedFHvdnaQ9o+vYCNk5V5EAia7W4Zb4O/rLgh2cmA/nlXfG bBROHSCcvADDOgTc77se+Uk/ebZXVvgRfUMOnt1EpDSQrKu5fwDU1B972zQ8pqoUEOBU St6/7J+fvBBjBrUdavgrIM9BPjK/sJYC8lHMRvgR7HPat/DkeIEJpqBm7ji6cVjS9tUn k3WU61LKH8c3OteupNK5jSH6L3z5UbLbhaqGCK7LrIbb4rqKtBiTdG0HTOSYsoO+18Vj A9CWaVlgnKpYtCQjOSa/iDyNCuxxmR5b4pylgeKQUxxFNEQzueFjZOuqzuNp9vWz7NO6 RrmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DZn0cvxZYBKzPVqxEZkVRGav/8WAngKpc5Ezz31M+PM=; b=VKk8eyERvmHyW/UnGV3BnvB20cDPMkrq43Z7kYqYDpCenh5QTYKD5DNwMd2+393Npy N29lStAyZtFdQJIRvT0f7YJwRO8SJlzHVFdq5aADpqT/H0EKs6sn63LFISxn9VifoT3f ursbUSUSilP2xbSe3nfKhAVNIGwpmBEH7ouKi+dUOAbPLQcaj4LtYCJtmMCV1BIwgTPN YZuK/Mue4ykqqETZ4niFZabdLYD3fRDXbhI4QUhndc/8GPpQV5gYajrO/GYKlqhmAPDi loW6K7SoqBOpEVVvQBCgxvOSUJXrxTQDJH8cndaMOV+b6KjXHUKWMRO8M8rbZUD+pdCn pZ1A== X-Gm-Message-State: APt69E0AEXSjOzcX5eQPCescW9FT7rbGq1HB2QBQXuY1VIaubZC6OJfX EqP9vweGElQuFqIk+4ou37w= X-Received: by 2002:a63:af50:: with SMTP id s16-v6mr14168594pgo.263.1528705884891; Mon, 11 Jun 2018 01:31:24 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id w1-v6sm81876177pgp.3.2018.06.11.01.31.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 01:31:24 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Greg Kroah-Hartman , Christophe JAILLET , Colin Ian King , Shreeya Patel , Kees Cook , Jia-Ju Bai , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: rtl8192u: add error handling for usb_alloc_urb Date: Mon, 11 Jun 2018 16:31:11 +0800 Message-Id: <1528705874-34845-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When usb_alloc_urb fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling usb_alloc_urb. Signed-off-by: Zhouyang Jia --- drivers/staging/rtl8192u/r8192U_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 7a0dbc0..3f09615 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1666,6 +1666,9 @@ static short rtl8192_usb_initendpoints(struct net_device *dev) void *oldaddr, *newaddr; priv->rx_urb[16] = usb_alloc_urb(0, GFP_KERNEL); + if (!priv->rx_urb[16]) + return -ENOMEM; + priv->oldaddr = kmalloc(16, GFP_KERNEL); if (!priv->oldaddr) return -ENOMEM; -- 2.7.4