Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2831286yba; Mon, 22 Apr 2019 13:52:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDpebFSn8FAnWppBQzSKfo0LLOhd27ePG8VofWy55W1lkWxaweSrk80wtkWJOGAhVlNRQe X-Received: by 2002:a17:902:e48c:: with SMTP id cj12mr21620374plb.93.1555966356163; Mon, 22 Apr 2019 13:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555966356; cv=none; d=google.com; s=arc-20160816; b=N8cN0b+EWtLAzfzU5U140DUG1ZhFOqJtRKLHVUMpWlvPOEGK4cXQsCVMRqKKq3YgAf fNhOTiU7F5h652UsqP38gkF5cqc/Qsyi+CEjp9tn0jt2kzbuBix5uUEALVX2RqarPISt gJech9htMushZZYLxj2Vy6TLOU9Q9CQlcvBnSpWAuhwK2k6iL+APzgLnkhYOP329k/xM O0v0uc7Mm+6BO8FzZdkxxi6y+15GcQG7TpbxPezzid8N4q/iRVH0CLqvmqcFZpX4RAwQ S59TN5dXmqmFVamWBClFpedNArmaXIfiSo/VC5e9zuihl5R5hCk/dIAqNGDjW+3rMF8A +Wbw== 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=mYtTQXJN7v11BdVzsgR0c0t8LpjBbW5N0kqrYHkt/yfTw2P2fW0ZEMto4cqUg480MM KSNWO/vM9/KejRCIf67b7hsbzUGZZctYP3g5X324A3VTvGyHhPA4l+e2WUhIxmcWcMYa jDN1LRT8XL0EKUrB+2bUJgrmeHu0WmaEqc1j5k5/PYxcwZmdLEIPJWa21lJDuM4IAEK0 0Z7MkSEBgBnmT4XOg6jkbhK0y3VYUuLiIwzHpGv+APyOyyuAWVoX7VA4jFK7i8BmzKfx /S0YFp1tm5ztP7qTFwU83ARGtbbVGjzF5GJY2Yu89eBjAsRn+IhqYnn8nAchBk/Jpc6A 8PDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LWD3ceci; 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 c14si14109430pls.106.2019.04.22.13.52.20; Mon, 22 Apr 2019 13:52:36 -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=LWD3ceci; 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 S1729230AbfDVTno (ORCPT + 99 others); Mon, 22 Apr 2019 15:43:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:44300 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728727AbfDVTnm (ORCPT ); Mon, 22 Apr 2019 15:43:42 -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 A452B218B0; Mon, 22 Apr 2019 19:43:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962222; bh=VdwnfoZOwTW/qkf1SJD7k6BhKVlobA00pdlu90t0HTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LWD3ceciaMpjACC+IHXpJGHi0wgavDAuZR5d1KS4I/cOjzX+Uh3DLnovtW7GTKW/r bjJqe5okIPt6k/aD706rkRO9iKq+07E1d1JkgEYUQEF2Ok+mT4yr9Y1K+h1IXBso2W UNeK3PFPYKt7x1q0WcnQEc1PuRQD790QIO/NUgHg= 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 5.0 44/98] staging: rtlwifi: Fix potential NULL pointer dereference of kzalloc Date: Mon, 22 Apr 2019 15:41:11 -0400 Message-Id: <20190422194205.10404-44-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194205.10404-1-sashal@kernel.org> References: <20190422194205.10404-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