From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC0F5C43603 for ; Wed, 11 Dec 2019 15:57:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 859F72073D for ; Wed, 11 Dec 2019 15:57:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576079843; bh=lFZkm7q6Kd6ZAtelJLFxe7PszsPAW7e1i73I2nPoQKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=g8X5GL3ltgNlwsvzGbHlECZiQXEYjLktASq4p0bXCZrgPxhdguF6ivCzuFR5h/iDB OSnD8WPf/msmiqFkdr10XmgK5GRVJm8nGhDCs9PHTBA9c0WgjdDWUGxCIaErKy4ZOo U/N7ufqdqwsFEYElb3yaw3lz1IxwrcH1SfOiphJc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731955AbfLKP5W (ORCPT ); Wed, 11 Dec 2019 10:57:22 -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 */