Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4499857ybx; Mon, 4 Nov 2019 14:25:42 -0800 (PST) X-Google-Smtp-Source: APXvYqx2UeJ9tP7R24oBax4u2G0END3Cw+MDRnlWCtTzL9q8amRe9wfPbiGpfWnNcr6ENNBSYJ+N X-Received: by 2002:a17:906:1354:: with SMTP id x20mr10829975ejb.131.1572906342383; Mon, 04 Nov 2019 14:25:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572906342; cv=none; d=google.com; s=arc-20160816; b=bRVsr3edGJ80w79t4t74PfY6Sh7rHQ9FKuwH3XETphctz/8dqjV+oo5j4rjLzjaXrw BvXzZcZxRC9RszjoIZNpKpacsbqW54ok83LllBlg+tVNW5CnJZHUrIxdW3qQb8/Lm+RF cMK5qpRUc+xcjjyL0qsEJ1C6KXAis8ggwpSenTknhtrz5sxIQ0+grC8jlNAAn1ERYYtb puj0OiDHuOO8KgDgeOEFAGp11ZcRhqutzipRSdk1aaVDiB5/UpmcgrH79Je8c2/+z/2G QMKTIAxZNhbE5A+77PIgBocCMdISOTs7zSkfAnedZhWm1TSH0yHmbnQhfM8YMc7K03Hr uNCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k7YWdGk8A56oIshiXt1KyeHEttO6oWwA+oWuNOiudPE=; b=LkenXfYOM526d3zMbgdq+sPp+g0RnC6n3/F8FASSK8KjRsT9u4Hbwn3F2q4bsg4Jl1 9OzWmHYHrDsjrGeTIeUPwnECH+ysCq3fPAFmUCZqhwakOSc5ApAhyipmj6WWejVUcl8v buwDve1PmSUG1Uq+RZ03+q4JhGBBplyFWUMJIb4nv07bUytxGeebGIFo1f7JzLvxO8lo X2bYRc0zqwSK4K/j288FfsnCAnyfd/Elo7Xa9dfK/xa6vXL3CIhQtsnAK9h5DACfIiuQ ZIqtyq3Z9LRNffIa1Se8B/oanOju1vBw3Mpk6CWpJXGT+V96wAapxNhD2RZfqTmQjJRo s1nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SB4PabLg; 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 r17si8549841edx.257.2019.11.04.14.25.18; Mon, 04 Nov 2019 14:25:42 -0800 (PST) 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=SB4PabLg; 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 S2387852AbfKDWYM (ORCPT + 99 others); Mon, 4 Nov 2019 17:24:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:47078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730881AbfKDVxL (ORCPT ); Mon, 4 Nov 2019 16:53:11 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (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 17FCE21E6F; Mon, 4 Nov 2019 21:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572904390; bh=lw0JyGOxgays0gFUTdF0ko9uxwQo/GwdpXu+mxHUcLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SB4PabLgHD1DG+7/5foq1ng0dhQsFTYfScCV6UF09Fxj9uhhAMOCntTFIiQtIh3Jl 8uFsaN9njh8Ok43tXqVCS5v6smzx8FXiSQCZxExVAMQ1/vPTwhc69a5v/r/2fBqj2w vlHOvO9pdg9BJpzTrkBajC2rCUrovpn0KmR7yoLU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Connor Kuehl , Sasha Levin Subject: [PATCH 4.14 30/95] staging: rtl8188eu: fix null dereference when kzalloc fails Date: Mon, 4 Nov 2019 22:44:28 +0100 Message-Id: <20191104212056.703969909@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212038.056365853@linuxfoundation.org> References: <20191104212038.056365853@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Connor Kuehl [ Upstream commit 955c1532a34305f2f780b47f0c40cc7c65500810 ] If kzalloc() returns NULL, the error path doesn't stop the flow of control from entering rtw_hal_read_chip_version() which dereferences the null pointer. Fix this by adding a 'goto' to the error path to more gracefully handle the issue and avoid proceeding with initialization steps that we're no longer prepared to handle. Also update the debug message to be more consistent with the other debug messages in this function. Addresses-Coverity: ("Dereference after null check") Signed-off-by: Connor Kuehl Link: https://lore.kernel.org/r/20190927214415.899-1-connor.kuehl@canonical.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 2fc7056cbff74..77c339a935258 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -357,8 +357,10 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, } padapter->HalData = kzalloc(sizeof(struct hal_data_8188e), GFP_KERNEL); - if (!padapter->HalData) - DBG_88E("cant not alloc memory for HAL DATA\n"); + if (!padapter->HalData) { + DBG_88E("Failed to allocate memory for HAL data\n"); + goto free_adapter; + } /* step read_chip_version */ rtw_hal_read_chip_version(padapter); -- 2.20.1