Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp7234677ybh; Thu, 8 Aug 2019 12:15:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSYI2hpHmXR2TBrlm6/4bQLimOz1q9Bt9prV6RLK/DvpPTavszkb8qjKxXCIsPgRkZpFmW X-Received: by 2002:aa7:8481:: with SMTP id u1mr16404883pfn.243.1565291712313; Thu, 08 Aug 2019 12:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565291712; cv=none; d=google.com; s=arc-20160816; b=fwJ0QTgFPhSgL3dKegolpEUC7GvhJ9Er49V293w4FjWFzkk8PIdYUwDn2tWs3oNP69 FmDdQB9Wy+kUnbUzjNVjw42o3H6/5x2ak/szDmE+j4TQnPDqHS7UuXCeik3WzkNObHNk tgvQ5k0U+PlP+08UaZ/R1vQPGKs6rP6oNNn5evjHfGNMNPkIWXWIl89ncd2jp+zsNLHX pXih7tEgVzbLaqnlTj4WI4zB9K4GL4sEj5ef/ewZnxZlSlfM0L2jDyiB/2QW29LALlRl w4j84RN6+Av6z3Abf87BBvzCBNgLmmCVd1L1d+xC0ByDIqzg9Gg+AR/W6Jgiu/MsqdsB y4WA== 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=kY+vzwcHzx3DHl1+TC1MLjAD65mqceZwCK36DbwdURo=; b=uFuVA7cSiRqCXrTv0mwdR1uaxZI+41oa4vijIElTGjvnwSAmPYldwM++UY6VPEn1E/ nTcqTjHZhIoNU1Fo45qXSqOXhCA6la15yT5Tm30RybADNuUC/WFLxC4aZqI8I14EtQNc 40cZe/2XR7qW4uj/Ajbay94a9y5cF41o/fjsahCausWKVR1IKT0rWgcU5POTK4cGW+cy H1yJmRZ66jb4w3VyixVOa8XghD16xpQfyNsW8CPAcemvTXvfa3MKPjovwLolVjPI/p1M 9IP45rfHnyfXhmXzDdAF+3sD9k3LYMGNvei3AJpvNvdj2/ZUYjy+mNNkwlm5pI7YtzuP g4/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=07sli8w8; 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 h185si49401766pge.199.2019.08.08.12.14.56; Thu, 08 Aug 2019 12:15:12 -0700 (PDT) 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=07sli8w8; 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 S2405106AbfHHTJ0 (ORCPT + 99 others); Thu, 8 Aug 2019 15:09:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:43724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405100AbfHHTJZ (ORCPT ); Thu, 8 Aug 2019 15:09:25 -0400 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 7D3DE2184E; Thu, 8 Aug 2019 19:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565291365; bh=X2mMx/M9Iz+bGpyx5Xo/mfNKmf2dnlq8TrSOT8/N1k8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=07sli8w8SkIW85DiUnlZgyODUuZuUhVbTRQ3MEUNxVDrIElqfqhv0RrDxZwiZ2+AQ M34P9z2ywvB0qANFGMoIx1vYWV0G2n2KSfteaax2ogNV43Lq2Fpr+gD5BFRnHX04hV NAlhkw3dcTBcfWA2PjkMq2H1W7vF2dGchnKUp8mQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+cf35b76f35e068a1107f@syzkaller.appspotmail.com, Johan Hovold Subject: [PATCH 4.19 32/45] NFC: nfcmrvl: fix gpio-handling regression Date: Thu, 8 Aug 2019 21:05:18 +0200 Message-Id: <20190808190455.577204678@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190808190453.827571908@linuxfoundation.org> References: <20190808190453.827571908@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: Johan Hovold [ Upstream commit c3953a3c2d3175d2f9f0304c9a1ba89e7743c5e4 ] Fix two reset-gpio sanity checks which were never converted to use gpio_is_valid(), and make sure to use -EINVAL to indicate a missing reset line also for the UART-driver module parameter and for the USB driver. This specifically prevents the UART and USB drivers from incidentally trying to request and use gpio 0, and also avoids triggering a WARN() in gpio_to_desc() during probe when no valid reset line has been specified. Fixes: e33a3f84f88f ("NFC: nfcmrvl: allow gpio 0 for reset signalling") Reported-by: syzbot+cf35b76f35e068a1107f@syzkaller.appspotmail.com Tested-by: syzbot+cf35b76f35e068a1107f@syzkaller.appspotmail.com Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/nfc/nfcmrvl/main.c | 4 ++-- drivers/nfc/nfcmrvl/uart.c | 4 ++-- drivers/nfc/nfcmrvl/usb.c | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) --- a/drivers/nfc/nfcmrvl/main.c +++ b/drivers/nfc/nfcmrvl/main.c @@ -244,7 +244,7 @@ void nfcmrvl_chip_reset(struct nfcmrvl_p /* Reset possible fault of previous session */ clear_bit(NFCMRVL_PHY_ERROR, &priv->flags); - if (priv->config.reset_n_io) { + if (gpio_is_valid(priv->config.reset_n_io)) { nfc_info(priv->dev, "reset the chip\n"); gpio_set_value(priv->config.reset_n_io, 0); usleep_range(5000, 10000); @@ -255,7 +255,7 @@ void nfcmrvl_chip_reset(struct nfcmrvl_p void nfcmrvl_chip_halt(struct nfcmrvl_private *priv) { - if (priv->config.reset_n_io) + if (gpio_is_valid(priv->config.reset_n_io)) gpio_set_value(priv->config.reset_n_io, 0); } --- a/drivers/nfc/nfcmrvl/uart.c +++ b/drivers/nfc/nfcmrvl/uart.c @@ -26,7 +26,7 @@ static unsigned int hci_muxed; static unsigned int flow_control; static unsigned int break_control; -static unsigned int reset_n_io; +static int reset_n_io = -EINVAL; /* ** NFCMRVL NCI OPS @@ -231,5 +231,5 @@ MODULE_PARM_DESC(break_control, "Tell if module_param(hci_muxed, uint, 0); MODULE_PARM_DESC(hci_muxed, "Tell if transport is muxed in HCI one."); -module_param(reset_n_io, uint, 0); +module_param(reset_n_io, int, 0); MODULE_PARM_DESC(reset_n_io, "GPIO that is wired to RESET_N signal."); --- a/drivers/nfc/nfcmrvl/usb.c +++ b/drivers/nfc/nfcmrvl/usb.c @@ -305,6 +305,7 @@ static int nfcmrvl_probe(struct usb_inte /* No configuration for USB */ memset(&config, 0, sizeof(config)); + config.reset_n_io = -EINVAL; nfc_info(&udev->dev, "intf %p id %p\n", intf, id);