Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4479820ybx; Mon, 4 Nov 2019 14:07:23 -0800 (PST) X-Google-Smtp-Source: APXvYqyqVruqaj/b9nX9Sg89xhvYC+Ak453epQMTTx4ZHHTZCx/tSrCxEzDz4oPGuFS0UBfVGpW3 X-Received: by 2002:a17:906:d939:: with SMTP id rn25mr19964321ejb.147.1572905243386; Mon, 04 Nov 2019 14:07:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905243; cv=none; d=google.com; s=arc-20160816; b=RxQvU0VdaxU8AVegk5fJk85rTnZjrKZFioHzfgwxOLbzRHLKO1WaOtcRfgugeTRlIw EZ+o4+VtOft8YcuHL9ArXQKOmMNbG8h+qwt/GL68LkEMIcJcDpcMlkpOHRVxsqvagKs8 +/mrfD9Q4iC4GAdBvuNkPzf2g0aSWVHllg7u8O2lxh9aC2V2Mtn1ibAzDu1jz0CrrC6x AmYMxtv1Kwkg5YZnmJ9vBFZXsHijykPeAfCOG5guxa1xwMsxSGTKkxikA2EqLlL657FZ zxoZezFReuoV7YNsotfQ5LWS4nKSFplfY45UhjZG2ik80KH22XfoHqSMxBwVRGrtEFds V1IA== 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=vUXW37paZ4cUR9PM5o+tEqGFmHi+fJxXNKk1LH3DVsU=; b=pM1kXf+9edUv9kma86PvKI9GbxAqgcMwkLPLGv13qIZokV1G4XQi7eOSVkwnm3pDqn dqxGo46vhFb6mlK5aZ0gP9+zPDa84QtYk6LpzE1vqWqTu64Ifgbq9/TAr96Q6HXRn1gW 94ZzTM9049jPH0yCha+ms6DPI83hsuAhkBw0UF0hO5NayU657J3TtOfCYEIMnrgjUMEE Q2gYemsIAbYNslp6SNmmN+QvdUd5lA2WNwxH2gH3i5kf24lhcwia1P3QQ6sKCI4pJXX4 2F7bube45J4IDmu6iJNKpqAbcU3cPhKtmOHtqVVuAhJir2iFInVVN3LAJk8ZTiRgVCxy sasA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=paql6eV0; 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 uz29si12799721ejb.68.2019.11.04.14.07.00; Mon, 04 Nov 2019 14:07:23 -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=paql6eV0; 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 S2389041AbfKDWEf (ORCPT + 99 others); Mon, 4 Nov 2019 17:04:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:35334 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388664AbfKDWEe (ORCPT ); Mon, 4 Nov 2019 17:04:34 -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 9F666217F5; Mon, 4 Nov 2019 22:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905073; bh=8b+rc10cF3+ehcKjsbukOG/c6H/IqWuM9gO4hAiVys8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=paql6eV0GRWXwqvz13MBNeqFyVfzS40x6Ug2SzSHQqkhCSk6buyd/E9qJdQzXNisp N6VFSrWfFHvgi2wUmR8c0bSqHH4RZZjbfRBH8sBgrhY7+lST9JRbLvRj1CntcBHGKD s9o0+E1FQkiqGfM7rd6M/M/6Da/R/TD2QDfMCiB4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Connor Kuehl , Sasha Levin Subject: [PATCH 5.3 020/163] staging: rtl8188eu: fix null dereference when kzalloc fails Date: Mon, 4 Nov 2019 22:43:30 +0100 Message-Id: <20191104212141.878157643@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212140.046021995@linuxfoundation.org> References: <20191104212140.046021995@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 664d93a7f90df..4fac9dca798e8 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