Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2917225yba; Mon, 22 Apr 2019 15:40:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRy1SDmMtxEP6oBZspnmw52Yw6+OcYNaV78C1dn3E3zo9+EoNO8ZvtoLXr+9nhf0O4Xljf X-Received: by 2002:a17:902:581:: with SMTP id f1mr22855656plf.304.1555972813626; Mon, 22 Apr 2019 15:40:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555972813; cv=none; d=google.com; s=arc-20160816; b=CkeLM1wCVe83KiFGjhwjM7Bz6bJwPhjzKTtsMiuSptjbuJayVS7jKDh8z6xY4V5nkW bqu7bMZKUn2Hb1UJKcUL8OUHh7fFJcmX/PLkjT0DpwZZl8bXW4wljiybyXjrXenqqwFm K9UvK18bjIwLOUUd0edAfwOpVpPgKrmFQVQKo6Dm3kYv2tOEAaI0oqjzPQg5yIXop2w0 3N1Y9+3WRbiukaqDTI5gOVuRMLSpQ2wr7olwFLvw0pKrkgNgZREtd0k+eqiglY5+AV29 thka1hl8lHcys+47M5/yYPeXZNoiWY6dnIdx0Hz68CIyQe2Cu4x7fvEC3q/n4Hfx5o8k vaxQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IBkWCIc0le2bT0zTIbiONaAayclXmU1toSBJ6nGCkRs=; b=TE/W5Gb3KYIux9DsQGAo82d1UlBJlayqvKOTMEGBiHaaO1qFYA+YU/R9ip0FmBiPNs AzdSmWEkXp/m5MQUYknokkjL6x0cooH48kmxpspabRV+U/OlqGh6Yc9IBVlfVzFKUxzV +z6WBooCWKavvwW76LI7CyZCll6VdzZ9b9d+qtOBNJS5Vtmflbps1/3oHZIswV0h0T0R NNmFWPioKBOWb/7zgK9cW6eD6PYAX832UR/kn+RdyQYeg64u4gi+YnyeU5Ypz9/03v4U SriVgMidHqovcFOGFtuekiRlGI/0o6uZYP00FUDVekJnMQaw7+oQelkD0eeiwL7bj8cB x9sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EE8HQ8CO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b1si14141455plx.232.2019.04.22.15.39.58; Mon, 22 Apr 2019 15:40:13 -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=EE8HQ8CO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730024AbfDVTqk (ORCPT + 99 others); Mon, 22 Apr 2019 15:46:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:48878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729986AbfDVTqg (ORCPT ); Mon, 22 Apr 2019 15:46:36 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 98D02218D9; Mon, 22 Apr 2019 19:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962396; bh=VdwnfoZOwTW/qkf1SJD7k6BhKVlobA00pdlu90t0HTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EE8HQ8COHevuv3kuohQVtUepTU3Iu0peMnVo9AMcVbwM/j91VpOO7cnc5iveK1RkW OVp+3BKr5Anrex7B7xQZoZrl66BCeZVhpIkGzOUsprfw6gTbvWG0X3YwNFDN2YR7Yl O2w0MXdnH+Mw3GLcrXef7mWT2vT4oARpiGmpLqpw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Aditya Pakki , Greg Kroah-Hartman , Sasha Levin , devel@driverdev.osuosl.org Subject: [PATCH AUTOSEL 4.19 34/68] staging: rtlwifi: Fix potential NULL pointer dereference of kzalloc Date: Mon, 22 Apr 2019 15:44:42 -0400 Message-Id: <20190422194516.11634-34-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194516.11634-1-sashal@kernel.org> References: <20190422194516.11634-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aditya Pakki [ Upstream commit 6a8ca24590a2136921439b376c926c11a6effc0e ] phydm.internal is allocated using kzalloc which is used multiple times without a check for NULL pointer. This patch avoids such a scenario by returning 0, consistent with the failure case. Signed-off-by: Aditya Pakki Reviewed-by: Mukesh Ojha Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin (Microsoft) --- drivers/staging/rtlwifi/phydm/rtl_phydm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/rtlwifi/phydm/rtl_phydm.c b/drivers/staging/rtlwifi/phydm/rtl_phydm.c index 9930ed954abb..4cc77b2016e1 100644 --- a/drivers/staging/rtlwifi/phydm/rtl_phydm.c +++ b/drivers/staging/rtlwifi/phydm/rtl_phydm.c @@ -180,6 +180,8 @@ static int rtl_phydm_init_priv(struct rtl_priv *rtlpriv, rtlpriv->phydm.internal = kzalloc(sizeof(struct phy_dm_struct), GFP_KERNEL); + if (!rtlpriv->phydm.internal) + return 0; _rtl_phydm_init_com_info(rtlpriv, ic, params); -- 2.19.1