Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4473449ybx; Mon, 4 Nov 2019 14:01:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwFAvQnDAWkr5oADAfK1E0OiMCS+eyVZU6+jN2V7ZhRdYVXkbE7c3XTEaJ4qsbXsKfwzA5U X-Received: by 2002:aa7:c1d4:: with SMTP id d20mr2932557edp.273.1572904915761; Mon, 04 Nov 2019 14:01:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572904915; cv=none; d=google.com; s=arc-20160816; b=tKk577VpFVnbBswqohjSKpSPzZmYMYCxXi6RLl4x0XGsak9jlSabEhZUfRjeuVdu63 iQRF93Jb9SFra9ssIZG3OUDp7BKi+XjaGx77lU62liXVqZLjWLzrySQi1lPFrzZnNt7J S2e0foCX6iq4EEfa2g0Lhhy2R0vBam06aUkjvVP2NOfilYbWlF58o59Uwk8Y79eizg4f MjhZ3T6Hwr+D7K6c2Tv5KOCrujuE1ilQOTiFaj+Bn92WICY2kNNVg85JG3CKxQ+0z9Ml GE+layMdcnq6HZ2uMgHQ8zjWf8qDR+jexy0X36idXtZNaxkL3W4Shm+fgoquxvXTn3nT fmkA== 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=Cwn/psmNyVYfO2ammPGnEx8nYr227duZ+kr/f5812C8=; b=pecLbw9zPdEdBnlBXKQHNrtOzfyr2ZufqPUDVs2JTHNxEH5s3wxKaKEGX3yg5U5Nme Kc+xyyxD/YiMcPDyFFbzoi4yA5dEWSHs1m+6d7P7+7OyCclRFMSsTTgAmqTjm2pCZEqr n9Y6xbUuJ4ipbCacdyJ28IcnPig6EC8FkKwEi8VRNyQCA7mhJP2obbw8TWFCMn8It1fb VLo8jaeahgS8MPTAl0fiRn6ixdo5/Q9wIcirmqiXCCBGi4vtAflGIZraQfqG7MNK+/vl /RbXVDEJ4POFMODmVpWj/EXsHzXIT/is/+3r1ttSdXZAqYGcBr2PAgJ+8rF0q4RStafB hWyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nEe6doKy; 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 d6si9344358ede.119.2019.11.04.14.01.32; Mon, 04 Nov 2019 14:01:55 -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=nEe6doKy; 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 S2388760AbfKDV7v (ORCPT + 99 others); Mon, 4 Nov 2019 16:59:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:57190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387947AbfKDV7u (ORCPT ); Mon, 4 Nov 2019 16:59:50 -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 E83DC20650; Mon, 4 Nov 2019 21:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572904789; bh=fMBUQEOmoxly6xWm/iIwvO3nP3iN5L5jNyhwQBwg8xI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nEe6doKy8hPdBTAMNJqs6V9FVO5gq4ehKKcJF9LkRLvreJS8vAYRE/GWbzCZRpKf/ EB/rmhV2wtXHiH34e+2JAcsgTIJzsosPJif6vbENzzJySxRnyz9nsBvJcatoIkEBYV TpEUupM5T+P2m64yJaxedcDvYS53OU17nfJfDjUQ= 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.19 070/149] staging: rtl8188eu: fix null dereference when kzalloc fails Date: Mon, 4 Nov 2019 22:44:23 +0100 Message-Id: <20191104212141.615664544@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212126.090054740@linuxfoundation.org> References: <20191104212126.090054740@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 dfee6985efa61..8ef7b44b6abc1 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -348,8 +348,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