Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1255290imw; Tue, 5 Jul 2022 06:30:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s4jySkopmnZP2A+5kjkmVP2mqKx1HS8adT/7n1UGAAIbiE9ZgG55L8+nfxiM8LYXCxHWPo X-Received: by 2002:aa7:cd66:0:b0:435:74d5:2d58 with SMTP id ca6-20020aa7cd66000000b0043574d52d58mr47150940edb.34.1657027854811; Tue, 05 Jul 2022 06:30:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657027854; cv=none; d=google.com; s=arc-20160816; b=HgR6b7eJ2zYbnlSKdgrP7l+WeAIrzSUGPIub9VueQuzDL1v85AiUNujUqzHycRMhIk pPLKb+n8YqpMd+sFBOfMauIQNbtY8jUxALi3XVtfzjNf1nVbGuGjSzygaRgHLa5Abtcc oy2vYonN9clZrZiGAwqMf70K5NjlC0lJF4fIn5EiCIeDUYcUayRkB0U2csuDuGwo6C7c ionQfxq3tWngAs4dkXv4H84V5AIP8BzFPenMXrirDRLc+9E+KZu8a27F7+6qV1XKJ+ZW ZDQY5JcTdqGArEccb2AaRY/5u/olaZSI3+qDzNvIrs+T6d7sKaD5mjV50Q5R0nuPddv0 66WA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7Dtmnzf+cx287apOmu59hsn+BJ+J7N+mZntsRbxLolo=; b=tm6wq9hX3jSrbts6Nf2PqytXPtLa0MRcxP8+5cGWmhWZhXdceQcFcE6KlpoBPNGp6p Rt1C+l8iPUIfZ2QU22luECnMjvjW2ABT4NyKH6sBl4+KtZn5AYDUdK2lB7wG912I83EO VRcuQjJ7Pz82+sKF1DRWVzNPMUBdd/vCHkIq0TMS7oZIa6fZfKknUFgHThkt1mijndCi EsjJvo8/9vzKNz/VNA2rSI/dXNN70FlUDd9DXw7PQKRF+wQycXx+df9xH7T7K3NHPUoa GBgTy4DarnTUVfT/Ei6wSGgQnC6Aa/BJ1eL2bSu0S62wNlYdERz6PLmdUujIc8I2LlII pxtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kDZYnXzF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he7-20020a1709073d8700b007046fc0f0ccsi21197136ejc.320.2022.07.05.06.30.30; Tue, 05 Jul 2022 06:30:54 -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=@linuxfoundation.org header.s=korg header.b=kDZYnXzF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236931AbiGEMSX (ORCPT + 99 others); Tue, 5 Jul 2022 08:18:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232197AbiGEMJX (ORCPT ); Tue, 5 Jul 2022 08:09:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75091186E8; Tue, 5 Jul 2022 05:09:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1251861968; Tue, 5 Jul 2022 12:09:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21691C36AE2; Tue, 5 Jul 2022 12:09:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657022960; bh=jzkFDmSMQEdcCXzeN1VJevw4S6A6EmA4JQDB+UhsubQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kDZYnXzFOio32WHkCLTRbToJ65Afe89Ir5mfxwPNurvJ5xJv2Ts39fV01nakQSAh1 eNvi44VDlpgNYvJfIw8Qcz+x+2B49rW5qGsDGMSADM6a5H5k6ErmNpWS0kHNQcQRKM G+1qiGkOKZQF1kcciyUqYgghyHEwFgKSZChwEMsY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Walle , Krzysztof Kozlowski , "David S. Miller" Subject: [PATCH 5.10 35/84] NFC: nxp-nci: Dont issue a zero length i2c_master_read() Date: Tue, 5 Jul 2022 13:57:58 +0200 Message-Id: <20220705115616.348329371@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220705115615.323395630@linuxfoundation.org> References: <20220705115615.323395630@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Michael Walle commit eddd95b9423946aaacb55cac6a9b2cea8ab944fc upstream. 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 Reviewed-by: Krzysztof Kozlowski Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/nfc/nxp-nci/i2c.c | 3 +++ 1 file changed, 3 insertions(+) --- 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 n 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 != header.plen) { nfc_err(&client->dev,