Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3708281imu; Mon, 28 Jan 2019 09:23:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN7ldosrdDlXxXX3Pfb7Tz/hbsXq0p2PjGmcmUkWlTgKkzo+lHUjmSpxPrCvBlabThwlk9e5 X-Received: by 2002:a17:902:584:: with SMTP id f4mr23223270plf.28.1548696217347; Mon, 28 Jan 2019 09:23:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696217; cv=none; d=google.com; s=arc-20160816; b=tav9Xp/NLRbAIqmdfrezGwAvxP2sxz5BaXvhlYR4TClVark+MIESJuT69fiTEujoBC 17SrV1ooGO/7W+qWtkqih/f2lLQKuZOEYSdMbOLshhGe7Wq15TT89W7e2cyGaqtbOSD0 3+nALRb/9gWX9fnQ5GI1spKnY3S1fYDamciKWSz4c5nfjxRhbCxe8k0OMZ30IP2uyJXi R3pshGaK2DbTkd7DYuIA3iHNrM31DxusojrLHq2Rt8zJpkxd4G2JjjmdWwyFhawmyUKF 6UsnrVALSMKPz+gghdYOJ1+NUv9N0h4YLNHKvzkOzcWOOwXQ7Ng9t//6xOrY05JFdrRH uOZQ== 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=b9mGS3VlGzrZL4/eJmpHK9DA+mjs7uewiLSmiIXXMPQ=; b=rHPKm55D+u/C6bJ5e1BwURjHUuQqz6oK+OL72slg96MlGvEnw5XHPQysxScsBGQhiM hw+/d9jbS0r63UppF0oY/xos4O2nyTpIbFBLXa4P9KPk02vZsQVjm3ubo+2socvJv/Og pyBaQmmeePWaO3eUB3k3/uFzE/HiTvs0dervwKOf1TvhRRSE+/y4PFyL24fNKs2JibxL HIqXBHWeyT3sSpFxBAjfWCuyGEggB32uCSG6OBeTedT/tUSn4p2XKfG7apCzcS19vBzM /cv9rkv5xZbpTGxbxIQv6zf8lb+qp7QGEKA9VDk8ecqkNvOQ9Rfyj7f9gqqOmQQ07jrh p2wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xFVAP5uh; 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 l17si32882596pfd.236.2019.01.28.09.23.22; Mon, 28 Jan 2019 09:23:37 -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=xFVAP5uh; 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 S1731290AbfA1QC5 (ORCPT + 99 others); Mon, 28 Jan 2019 11:02:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:48216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730539AbfA1QC4 (ORCPT ); Mon, 28 Jan 2019 11:02:56 -0500 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 570D821848; Mon, 28 Jan 2019 16:02:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691375; bh=lEX+ia60M3djuw6C16E24APAvdXawfM5EyjrBZYoZK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xFVAP5uh9uPe1hWbTviRVPp/JoWXSYO3PVdwDbZuwyheiojZWmB7SnDMh6ybzhfI0 Bs4McMc7lG2NCwDzUrtnQ1PCEGhDih4LS6t32NNRrpgaZEzWOUQDYmYBgpTODLCzMj uwmjHJEDnGBk52XhOz4NtWeAcvIoYCSaD+E2W8pE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Michael Straube , Greg Kroah-Hartman , Sasha Levin , devel@driverdev.osuosl.org Subject: [PATCH AUTOSEL 4.19 071/258] staging: pi433: fix potential null dereference Date: Mon, 28 Jan 2019 10:56:17 -0500 Message-Id: <20190128155924.51521-71-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 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: Michael Straube [ Upstream commit 64c4c4ca6c129a4191e8e1e91b2d5d9b8d08c518 ] Add a test for successful call to cdev_alloc() to avoid potential null dereference. Issue reported by smatch. Signed-off-by: Michael Straube Fixes: 874bcba65f9a ("staging: pi433: New driver") Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/pi433/pi433_if.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index c85a805a1243..a497ec197872 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -1255,6 +1255,10 @@ static int pi433_probe(struct spi_device *spi) /* create cdev */ device->cdev = cdev_alloc(); + if (!device->cdev) { + dev_dbg(device->dev, "allocation of cdev failed"); + goto cdev_failed; + } device->cdev->owner = THIS_MODULE; cdev_init(device->cdev, &pi433_fops); retval = cdev_add(device->cdev, device->devt, 1); -- 2.19.1