Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1945814imm; Thu, 24 May 2018 03:23:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZprb9bRdUxHCgGEyKvKHXkhAL8vv8ewnK3VjrLJo9fUq4X6KVN5BgdzFM5nHMsbp22FF7wr X-Received: by 2002:a65:43cb:: with SMTP id n11-v6mr5264277pgp.287.1527157415896; Thu, 24 May 2018 03:23:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527157415; cv=none; d=google.com; s=arc-20160816; b=MzMr7mJJZ9ioOz8tHZ6N52aCmlJqTag1qyJVnInhYHzHkXgnDY3TvXFRnqyP0FIkJd YnkYBFS45RUpkCVVX8gr7IY9rPY+2pIDDw8Y7OUUE+Op1Soqu7eICdXximMADddrptFW hTn5MPNcMGbCruFrkKTpeuEYAo8I4J+oP/RhrBDNU67y1Z4pAIhgwInJv+GH/cXUZHjt oao5lxE4ztiMumoNvp8vqR9bgKdD4Wg3iKfWS2tSlIzPS4VPjEDizQ8JsQtgLgQT+DDt rdmR8C07Iw+LK4vW1rLWiGRuY13i+2KMFf+bV1DoP0hS5PoL2Sd2Hrc4C1yKu1KTTjkU mynw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=kcSg4QVFZTlbn/28EmTV7Z0x5wmW68FaidsW8wRz9cc=; b=Ujm5A7mvcIpAgUz4zIgw5NxiaWPqsJYqsm6uY9e/SnUgwVGMK2c7KrTk+gOm1nNHF8 /pfZzDGEaz+DO6qEDi/ehgGerUTIxEFCQ3+xUQ6AnrL43jjagf0uKxQeW68v4iwUVqFG khFqJSqHyj1wmjqY1iC3Wzp/CZ2/M/YjLhMYo7IOVKGKD9Y0WiYYH4Hq1pi8+szMh6ox heSEKHtFW01tkBi7mm3Jm2c0qvW9YIt0jxNMimnw1QjZKYgstmezXG2EV5NbxQA9ORDB +TQJyofKuayNPxdscga1zN+onAk/YmXJKIl1obtWEKmbcbcpwxso41DBpo4DcR1B+liR klaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GpUO1uuD; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay9-v6si22402053plb.259.2018.05.24.03.23.21; Thu, 24 May 2018 03:23:35 -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=pass header.i=@kernel.org header.s=default header.b=GpUO1uuD; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031909AbeEXKVd (ORCPT + 99 others); Thu, 24 May 2018 06:21:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:51614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031214AbeEXKDH (ORCPT ); Thu, 24 May 2018 06:03:07 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E6F4E20847; Thu, 24 May 2018 10:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156187; bh=JIf5bdTAYHb7u3nC+dEzk2C1yUN94P6YSOtKO/aSoVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GpUO1uuDIqoKjZowXP7z0P30wv2ZbCKSKywepnWGSLz0B8hU34H1nWgZmpyff3Omk skEDQ7MLy3wwZv0ezIKUju82sppDIoL0QK59xuZ6cHV7yxIJH5MyLf3yA8w7yYKN3v A8RSLNeekrZm0qXrQuko/2G6sq2GyjhKlYWrRAYk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Sasha Levin Subject: [PATCH 4.16 094/161] staging: rtl8192u: return -ENOMEM on failed allocation of priv->oldaddr Date: Thu, 24 May 2018 11:38:39 +0200 Message-Id: <20180524093029.668964876@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Colin Ian King [ Upstream commit e1a7418529e33bc4efc346324557251a16a3e79b ] Currently the allocation of priv->oldaddr is not null checked which will lead to subsequent errors when accessing priv->oldaddr. Fix this with a null pointer check and a return of -ENOMEM on allocation failure. Detected with Coccinelle: drivers/staging/rtl8192u/r8192U_core.c:1708:2-15: alloc with no test, possible model on line 1723 Fixes: 8fc8598e61f6 ("Staging: Added Realtek rtl8192u driver to staging") Signed-off-by: Colin Ian King Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1706,6 +1706,8 @@ static short rtl8192_usb_initendpoints(s priv->rx_urb[16] = usb_alloc_urb(0, GFP_KERNEL); priv->oldaddr = kmalloc(16, GFP_KERNEL); + if (!priv->oldaddr) + return -ENOMEM; oldaddr = priv->oldaddr; align = ((long)oldaddr) & 3; if (align) {