Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4505972ybx; Mon, 4 Nov 2019 14:31:16 -0800 (PST) X-Google-Smtp-Source: APXvYqwiGkqJEjXbCAQ2IxKs2nwD8p+EF7MjLmO4imWSA3rPFqt6Q67OCdnZU4CVnSbVtOlVfT6x X-Received: by 2002:a50:ff12:: with SMTP id a18mr31792147edu.200.1572906676180; Mon, 04 Nov 2019 14:31:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572906676; cv=none; d=google.com; s=arc-20160816; b=yMvDrlp7o0Z1GMSU+OFK3t4aBAAsTqzfaj4fbCSAfgaU3/2ggc1rx3zO25KbagvxWR cp9vC/s2owfn31J/G9epxuA+dLsTDLMSpuCaAfsaPKTGYp1VMX99jW4ThZMKJentDRuQ 0FzFGeh9DEG7SDV1WiRKYVVZRciVGnAWz/BN5wkOZgrvMq3Ul7RUHylGjWaC3r0U+ryZ taMl8ei5y+p8+DIpMlLPe9zsVxVMKDLFv3NCoL5DZWeJUorGbsbfNqHB1S1Clza67khO hEdCEOdX1A+Mxd4NQELhu39ZIYOQb+pmac8w2gKDZxbzPOxg/LggquTRBJyiJXU/hD2E zIIA== 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=Wp2bZfrAnTGjYJrJyyqvm5wyQswXxs/qeYW0YkhxixQ=; b=YWxOVOqtLmaZD+9FBMC9OtxQvhcj2BziCc+mO6YXMqRwnxhU0etO/35ib1DJN9WgV8 o8Q3YzAPMMMai4eLBNn5/L1pMJGNLqrmll3JRFZFjR9dnhbzwnj0C8g619aFtAjxxJao nV7yTLRHXAK/K/35OKgceVOtjRgUs11RZwzDF41CbAn1z3UMJs7/rIXCXMnMLLNlJqnk iypmatUGY+kzW8W7OHlRs+Zno9sS6uHH8J9Zla3LNDpzuCIM8XQD6TlPKV4BEH2H9nfB 21mkKqyydZIivhbKaS3YBQpfFMYzTNkGVYPnSQYDcZUuT2jmDUrV2/PD5rdKrHCAITmh UKdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Us0dd235; 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 w32si8115671edc.443.2019.11.04.14.30.52; Mon, 04 Nov 2019 14:31:16 -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=Us0dd235; 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 S2387574AbfKDVt7 (ORCPT + 99 others); Mon, 4 Nov 2019 16:49:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:41706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387561AbfKDVt6 (ORCPT ); Mon, 4 Nov 2019 16:49:58 -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 CFF4F20B7C; Mon, 4 Nov 2019 21:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572904197; bh=oRp6FLuQ2dT5U3OHIfhPQWl85hmIQQJT7IQ+xrwJ9uo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Us0dd2358sgwNfbX29hgdPoV8kYhREL7GApfFtuE5gTd2kJHBE/aDtdgTDCHJdaHY EqI+1oZZay8kOCZ2CxeYylGGhfPYRx/ep3U/bBOmHwEHjFeDJphIFFYA0h6SuKRC7G +e0HXUg8FA39M3StuMTG9sGuvZYyegj73zKigBAM= 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.9 16/62] staging: rtl8188eu: fix null dereference when kzalloc fails Date: Mon, 4 Nov 2019 22:44:38 +0100 Message-Id: <20191104211917.339403959@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104211901.387893698@linuxfoundation.org> References: <20191104211901.387893698@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 d22360849b883..d4a7d740fc620 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -366,8 +366,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; + } padapter->intf_start = &usb_intf_start; padapter->intf_stop = &usb_intf_stop; -- 2.20.1