Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2724987imj; Mon, 11 Feb 2019 07:33:15 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ+pp376+xzhnOPnUDMYC7rTXkIrzfoXZqVK39cnP+FuV9M5kyxyE0/HneW/ozchH1Frs1M X-Received: by 2002:a17:902:298a:: with SMTP id h10mr38308105plb.312.1549899195574; Mon, 11 Feb 2019 07:33:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549899195; cv=none; d=google.com; s=arc-20160816; b=j89hxPovOH83sp5Z1ygtkpit4O07JVLH1Iurgi1H5U6mwB+E+VImSDtc9Vmorg9vlS rE2tv23MGNV+U2k+FpPtx8GApJELj2n5s7D2GyCLFVMDJRm1p0++W0P04dlcacusXE0l yDQWKlyMXJc0iWJJbhqoj5uci4s+KW5kEPg3HqLgkPPhfA1QBrvv8YYCnR7BsMG91SFq bOaaiYwL0ivlMrhUBwcOTwC1EqxIM2otlimdijUzxvSDfFmx/BIZw0bjsVm22D7uL3xm BcKn7gy1XVx/iqJc3r88bn0moU9Sp3gdaax8o9IvPx3XyNnzf6lEVkUp4y14ZCH0Yqqh 9BSQ== 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=HpHKxu/J8iRg4Vc3rtbDF5QczAIIfC7TqJmvjYHE1/0=; b=kTGal2qUkwK87EXAXpTGQwIJm4LChTHlm0l0DEpmYFTwJBjQ/YvWQAsyGJcWFfgT+n xM6DleJ5Q2+202RL1IdFvkex/dRcsZ132vNqfEfzrfPXcfoh/kLBrneIsRjat1gEjTQc a9QFjNCuD/UWlwm4do1fRoo4bplzRXPZ9QsBIcXaYY7aooPix++aIewhiMiuJQqKzhQ/ rf51hjpXFkl35INCnMSrNoDuGKoemy3eg2XliirkaC7xGIcK30Pk3cFKsHXkDvusmVuq oZBG/A5Ym83ePf5tUgIkIuX9qWXEDv4N/y2W0f/3/b7Q3P2hWkKGUPCt72sRTbbf+suU vk1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FKPjstD6; 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 g4si4748219pfi.233.2019.02.11.07.32.59; Mon, 11 Feb 2019 07:33:15 -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=FKPjstD6; 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 S2389028AbfBKPbb (ORCPT + 99 others); Mon, 11 Feb 2019 10:31:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:42940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389048AbfBKOzu (ORCPT ); Mon, 11 Feb 2019 09:55:50 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 81ABD20700; Mon, 11 Feb 2019 14:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896950; bh=Ik6nIoSd0YJD17c3CJwXtxh0eY3CDBSEWw7xAyI3Eu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FKPjstD60poexLoYsYXNC9eEvvw8ZL5exuqargkYb7hbC1xnhlaxJ21xnavFiIImr jvviqEDf5aJOM4xCn0tisyw+fel7TOukKkT1i+SNNQkUR4eaKLw4tk0nqDuW4UqKYK pwozwvk/XhJogve8c6XrHycShwafrfbNHtyK22QM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Straube , Sasha Levin Subject: [PATCH 4.14 041/205] staging: pi433: fix potential null dereference Date: Mon, 11 Feb 2019 15:17:19 +0100 Message-Id: <20190211141830.771869543@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 93c01680f016..5be40bdc191b 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -1210,6 +1210,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