Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2768186imj; Mon, 11 Feb 2019 08:10:56 -0800 (PST) X-Google-Smtp-Source: AHgI3IbsyY1XuIYPc3kmqDkQWnLE3ZbXvxCfFpUQRIQhY7FHAaMDXHWcNsZL8gOJENV2dq2mDiX1 X-Received: by 2002:a63:cf48:: with SMTP id b8mr19483748pgj.17.1549901456217; Mon, 11 Feb 2019 08:10:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901456; cv=none; d=google.com; s=arc-20160816; b=C1Gcj2jloze4D5xa1zv1o8kOPrFxdQQnsj/+fhqOmBUa7lPEzKnPNaun7yY8HaUf/h Y8Hahxzp7c0Hdidjw8uWCT/Vi/SYfXjsnsglsuhNKT4sTfWKOYqGAIT0rEIGVErKrCWT zXKW6EleZKomUbMO3vYzq8kYSRX6dL4jPYorECGS6xqMvRHPL065LpWD10WLaCXbb1KG 6e+gD+tkTpoW/dnADAz7ajHMFEna5Nb9Pg2PYpFh65nyCX5H7Yu4FH5BfP0lPw7VxMzA bjD9n0uUZ8LmCc8J4EqPQp9i29/8TQ232xz05smzsujNQYEMrdo7yl8MVDoEqv1S6JFE aTfg== 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=e3oBGStEBUC1y/sV0GX68vUApV1JkdrsqFxzmaiD08I=; b=JLiLKYV+B4SeUqulm6PZ0fnctZzEPDGz0EmzCjl9zhXSgNCT6/ZnusjEGmSkpy1ezL CWbWyXznM3DF+5MQS8AO5JY2GhvuY/AgsQwW2B8lj+9UScd0rGiYZHwfzrefVoIgiJYY 8paP/obESfBeOUmHGC8qWEpVIqxmVZt3NCjqtsLgUIX4gSfInIj9gFVw6xSuY69S8ibu 82znKErv/2QZckmViDmqv+sYI4bH6P8grFyCRj6YAxhVbaWyA7Tz7wKCf8m0ZaKJNRx9 bBGBwmHr4jKaANK8fCTAvs8PmaMIa10izQWUHrG6Ln0Z9vJpg13K4jNIPjhr4vCrVvNy 3Fsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PGT3AMfE; 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 u20si3112006pgh.147.2019.02.11.08.10.39; Mon, 11 Feb 2019 08:10:56 -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=PGT3AMfE; 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 S1729358AbfBKOZU (ORCPT + 99 others); Mon, 11 Feb 2019 09:25:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:58582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727216AbfBKOZL (ORCPT ); Mon, 11 Feb 2019 09:25:11 -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 9799B214DA; Mon, 11 Feb 2019 14:25:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895111; bh=XMVLi8YD2vSIedJuozVCeKF463CULcOVzWiHS/CEM6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PGT3AMfEPSsk0DDJoXnwyoJAJWDWERfL5ZBSqkiOvOAXI9oBbyD9FQ5VUBSm2OzMV De+RrnriWHJBXhj+NeBvXJHtwFXtSkZhF3LTD3d0he5j5LpxCK5HLdNU3FoV/hUzb4 +MjUg6EcuunnDjE0+v7CVxjhzt7HPT+HQg3KWSn4= 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.20 078/352] staging: pi433: fix potential null dereference Date: Mon, 11 Feb 2019 15:15:05 +0100 Message-Id: <20190211141851.007917054@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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.20-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 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