Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp817736ybl; Wed, 11 Dec 2019 07:59:32 -0800 (PST) X-Google-Smtp-Source: APXvYqz3/7aamkQlW4pqmPE254UZqi4hfn8rDamK2THxlSePwJUa96STXd2cWHSvDDKOKSYRfBBB X-Received: by 2002:a05:6830:1353:: with SMTP id r19mr2883060otq.288.1576079972217; Wed, 11 Dec 2019 07:59:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576079972; cv=none; d=google.com; s=arc-20160816; b=A08CPJgZgzrK+GZzkpSa6D+++VlVBzBXqDBZrzQFy6IM/vYOr/UEsLjlt5m4e6iHge pvU6HW/ONPe+o3waw43GKoBDDhZFkiGJDtgwF7JW0gQn0GDRiAnrx9QfJOUgcLK8n6mx J8MMepLG26gyfvifyNh7OVbKZcOGCZ2kKIihKrdjRl+Am5rm6pr5w5wMvgbdJuZhZxRO Av7VS7hdCLzzGFahQVK0hf/HZxUkwivY6WaM4fvMR/zfN13UM2TXN1Fs0jKFBCeD8W+4 O44oBGyy01LsLhMgpNRmdP6yvDJ0tj7HVCVJ4+cXd6EbgjkZ8WmtNI7DA4NQXGApcHxo thMg== 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=OWN4uyAMWnG565oX/IDGqlsSmrSBbQTWYGCK9LLH92o=; b=p3Q76pAwy/1rx5MkmxaH4qJ32e/hsUccW/4Xj0V1bZejofoW1DoiCuGlzJ6SeXUkb8 GhRBuLIeGtamdKni27pW6/5UXaC6nfNz63JnEJkIyUqknSFM9ogbufFQIFP7HJYSPHWD ne8a5L3Omk46yoBpy/mAgFl9GLOpA4yMNPWMD2UBITqrph4WcwyDE0xJ8A6YVlu9geyJ WDH2YkThGliwgUzYSL4sVpXj5K3/5Q5+J0rY+fdevXM4fEPqow+zR7sByZn5ZadmQxL9 MJkE44SyHk4FH0TutlUNrFeiy3lt47Sh9iNPW7957+TYs9Y6OzbWBo33naTt5Lr0ynk4 ENbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="U/D+8Fm3"; 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 e1si1444635oie.168.2019.12.11.07.59.20; Wed, 11 Dec 2019 07:59:32 -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="U/D+8Fm3"; 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 S1731826AbfLKP5T (ORCPT + 99 others); Wed, 11 Dec 2019 10:57:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:41124 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730503AbfLKPPL (ORCPT ); Wed, 11 Dec 2019 10:15:11 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 1C31A2465E; Wed, 11 Dec 2019 15:15:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077310; bh=lFZkm7q6Kd6ZAtelJLFxe7PszsPAW7e1i73I2nPoQKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U/D+8Fm3jW43WlSJRIY61Y6NCapVyJeYBiKC6typYdbjNBpb19j87hDTHV0FWRNbj FhVBhS6L4aDJiS98+kDKu4cg4o6lYSElp6cnQBA84EE91JgqzY8P3/UQGZyWGCqVEW 2JZ5Tufq5QUqv1bNJ6FgIg2m0nnn2P7nTX3a/Y9c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "kernelci.org bot" , Gregory CLEMENT , Mark Brown Subject: [PATCH 5.3 097/105] spi: Fix NULL pointer when setting SPI_CS_HIGH for GPIO CS Date: Wed, 11 Dec 2019 16:06:26 +0100 Message-Id: <20191211150302.501151205@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150221.153659747@linuxfoundation.org> References: <20191211150221.153659747@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Gregory CLEMENT commit 15f794bd977a0135328fbdd8a83cc64c1d267b39 upstream. Even if the flag use_gpio_descriptors is set, it is possible that cs_gpiods was not allocated, which leads to a kernel crash. Reported-by: "kernelci.org bot" Fixes: 3e5ec1db8bfe ("spi: Fix SPI_CS_HIGH setting when using native and GPIO CS") Signed-off-by: Gregory CLEMENT Link: https://lore.kernel.org/r/20191024141309.22434-1-gregory.clement@bootlin.com Signed-off-by: Mark Brown Cc: Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1779,7 +1779,8 @@ static int of_spi_parse_dt(struct spi_co * handled in the gpiolib, so all gpio chip selects are "active high" * in the logical sense, the gpiolib will invert the line if need be. */ - if ((ctlr->use_gpio_descriptors) && ctlr->cs_gpiods[spi->chip_select]) + if ((ctlr->use_gpio_descriptors) && ctlr->cs_gpiods && + ctlr->cs_gpiods[spi->chip_select]) spi->mode |= SPI_CS_HIGH; /* Device speed */