Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2336327iog; Sun, 26 Jun 2022 13:01:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sbUwP2e+Egn8gBqIF6lSd4J3RPfky2XYGPQuRpvW46DhUSg3FzLkQp7Eg8C8vk2GUKL+av X-Received: by 2002:a17:906:71d2:b0:722:e899:5dc2 with SMTP id i18-20020a17090671d200b00722e8995dc2mr9406823ejk.163.1656273677351; Sun, 26 Jun 2022 13:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656273677; cv=none; d=google.com; s=arc-20160816; b=Mdjnj58x24q+Ff+BMMsO0/eY/3crZhGV6vV6ftG0h6QZWULnA/NeHhPqOU+T/ut7is s2hdU4vCEURZFT+dpN1riYqPngeFMQGgeROmHsGW0hnJwG6njKQk7U+sZBBaSnL/cMwA 7QtynSr4SN4XAXOLJH79AKBt6205M1FYgYna7Pg/ziVnYAMnLMsdFmUiAcupNq+1ri4H w7x7PCiVJVDYHJ6j6qHxhjsjl8FjX0x+MfRlqN+L+nXthOGqxoQJ9k3X86gc3v8RR6Hs x/OsHjykP5Ua3onIeNQlfizGIz1flTl64rFvnZglnCYBWgEkFUJyswZbp2oTrBw4oDMA sX8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DG1TtMgcwFPG6kIPYW21bB1MOFqKbpqr3fn3fLeFTcU=; b=IthI9Q85n11/7RyeSo8vIvfgcssNfSG4C0yBGQmsMC/ALyOXtg1qd1IueqNs04uTsc uTQ4cN6yzccoUjeE25LyQbJ6Xm78SPkxtTUQ6na022aAB6aTJYonaymdvNtOrkd1t4jq Ztxe3pR5S+dnJeVZY+P//JCdRYLznEGXkA7mYzOKgX4lC2LuCVFzt8l88PPZyne6RiP/ DBcjPksiinW8TSPOf8DpHp0LkGKzz3cMIkDR0SbeP3ZN4x3uFW8Oe7wwGkwS6i5AXQdC UqBYOadcjmHuexK9otMYMenPcw4hC/4Vf8TsT+FjyJZE4bgT/8In5MkiiYwh4kpJlNbi UhDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=TSj13tGk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j18-20020aa7ca52000000b0043564d6960esi9419807edt.499.2022.06.26.13.00.52; Sun, 26 Jun 2022 13:01:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=TSj13tGk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbiFZTm6 (ORCPT + 99 others); Sun, 26 Jun 2022 15:42:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229492AbiFZTmz (ORCPT ); Sun, 26 Jun 2022 15:42:55 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B273208; Sun, 26 Jun 2022 12:42:53 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id A327922248; Sun, 26 Jun 2022 21:42:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1656272571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DG1TtMgcwFPG6kIPYW21bB1MOFqKbpqr3fn3fLeFTcU=; b=TSj13tGk7jUP8vRP1Keg1Griw5QTYTnm7tjZixfTJWAaz481wHvxRxCZ/EaaRMXQRGW6AK 9PkFzlr8jpnOL9mthTHK+LSt6NGempahXaef/Ljcue9YYJ2yeYhm7s8uSjSp6NwLwJQ2UX IwaeqsdgHG+MjZp1iEsFeHu+CirzN1U= From: Michael Walle To: Charles Gorand , Krzysztof Kozlowski Cc: =?UTF-8?q?Cl=C3=A9ment=20Perrochaud?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH 2/2] NFC: nxp-nci: Don't issue a zero length i2c_master_read() Date: Sun, 26 Jun 2022 21:42:43 +0200 Message-Id: <20220626194243.4059870-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220626194243.4059870-1-michael@walle.cc> References: <20220626194243.4059870-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are packets which doesn't have a payload. In that case, the second i2c_master_read() will have a zero length. But because the NFC controller doesn't have any data left, it will NACK the I2C read and -ENXIO will be returned. In case there is no payload, just skip the second i2c master read. Fixes: 6be88670fc59 ("NFC: nxp-nci_i2c: Add I2C support to NXP NCI driver") Signed-off-by: Michael Walle --- drivers/nfc/nxp-nci/i2c.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c index 9c80d5a6d56b..c9361b5249b7 100644 --- a/drivers/nfc/nxp-nci/i2c.c +++ b/drivers/nfc/nxp-nci/i2c.c @@ -162,6 +162,9 @@ static int nxp_nci_i2c_nci_read(struct nxp_nci_i2c_phy *phy, skb_put_data(*skb, (void *)&header, NCI_CTRL_HDR_SIZE); + if (!header.plen) + return 0; + r = i2c_master_recv(client, skb_put(*skb, header.plen), header.plen); if (r < 0) { nfc_err(&client->dev, "I2C receive error %pe\n", ERR_PTR(r)); -- 2.30.2