Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3666889rdh; Mon, 27 Nov 2023 23:40:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHT/AQxQQ2/NTcYMO9AqQtRFCHFHE+jSI1/l5SxirIZ0973y4V4pqyTU6LNKVwFiMiTOm1d X-Received: by 2002:a17:906:2091:b0:a16:7f44:25bf with SMTP id 17-20020a170906209100b00a167f4425bfmr23956ejq.17.1701157233826; Mon, 27 Nov 2023 23:40:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701157233; cv=none; d=google.com; s=arc-20160816; b=I2SfJoIyEOlG4eyhmGOE8P+B0HCUj6Sus0ZN7H52UYEltOG8xI61KearMdev5odmoW 4A0V9MMWJDSfs0+ijRF7ZXezGyMa3VGxLc00xhmHLiu1jeqykueG7sgbf1pKZiLSzdHk osPynnQRZgTEyBkE7MaLG2AnvV7/FtiryUAal82T/kGWyspmIYJGH0HT1li9fkrPbfvH +YUIdBl6LCVplQ/1BVEBLZiHD3qH5h8xRozgD1U8vLmB0ebO2TixYfEgZLMFwJj/Uqnp 9VZc7at5TZ0G+VsR0POvRkBQ9nVU8Q+HE/BIkhawhLZEEF7aOFQOx6HuOoArBgaOgYoc GCBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=a3MsrId7uS5Bey6tIPTNRp9GigT5e8E51uRbK55yG1k=; fh=kCgUeXDnK8Y2Fnne3q8cKOhJ8SptOVkvz3q3MtRQi1M=; b=wYwyZcaWBdtasb0Gs3z/arjvWWJPUdXJGCqIH3P6CYD/1CE5G5iIhxo3wR6r+cJVL7 bafKxugtlzp2o49emVumklaPdTiUzpNKpivN3FtcB4NeA7VlE+jTSi+RKtwgy/GU2Enu ZiO52212Bf1zDkGjC8GTK5MaGRBjC2M5xwXimfrjh4yS75uJcjkjJ4r+bIBASDeTSQFj 5qzdG4kOCYelMLG4hpp9+dPPOth7I+kNGG3hB1ODKtwZRmwCEjvHFV4t+Axt5sfvrmx1 onjZE/SGe49l+JBhX8B0/6RtQH90/Pbz4xgAijGyfPVpTGo3Os3AFBMpQ8rcKQ9AS0U3 xHSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth+bounces-264-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-264-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id mc4-20020a170906eb4400b009feb3a43c23si5805042ejb.843.2023.11.27.23.40.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 23:40:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-264-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth+bounces-264-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-264-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8AFC01F20F50 for ; Tue, 28 Nov 2023 07:40:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 350BA14003; Tue, 28 Nov 2023 07:40:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail11.truemail.it (mail11.truemail.it [217.194.8.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44928183; Mon, 27 Nov 2023 23:40:24 -0800 (PST) Received: from francesco-nb.int.toradex.com (31-10-206-125.static.upc.ch [31.10.206.125]) by mail11.truemail.it (Postfix) with ESMTPA id 7B50D2074D; Tue, 28 Nov 2023 08:40:22 +0100 (CET) Date: Tue, 28 Nov 2023 08:40:21 +0100 From: Francesco Dolcini To: Jiri Slaby Cc: Francesco Dolcini , Amitkumar Karwar , Neeraj Kale , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , Francesco Dolcini , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: Re: [PATCH v1 1/3] Bluetooth: btnxpuart: fix recv_buf() return value Message-ID: References: <20231127191409.151254-1-francesco@dolcini.it> <20231127191409.151254-2-francesco@dolcini.it> <5f2995d5-3c7c-4234-82ef-dd43bc73a730@kernel.org> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5f2995d5-3c7c-4234-82ef-dd43bc73a730@kernel.org> On Tue, Nov 28, 2023 at 06:23:21AM +0100, Jiri Slaby wrote: > On 27. 11. 23, 20:14, Francesco Dolcini wrote: > > From: Francesco Dolcini > > > > Serdev recv_buf() callback is supposed to return the amount of bytes > > consumed, therefore an int in between 0 and count. > > > > Do not return negative number in case of issue, just print an error and > > return count. This fixes a WARN in ttyport_receive_buf(). ... > > drivers/bluetooth/btnxpuart.c | 7 +++---- > > 1 file changed, 3 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c > > index b7e66b7ac570..951fe3014a3f 100644 > > --- a/drivers/bluetooth/btnxpuart.c > > +++ b/drivers/bluetooth/btnxpuart.c > > @@ -1276,11 +1276,10 @@ static int btnxpuart_receive_buf(struct serdev_device *serdev, const u8 *data, > > if (IS_ERR(nxpdev->rx_skb)) { > > int err = PTR_ERR(nxpdev->rx_skb); > > /* Safe to ignore out-of-sync bootloader signatures */ > > - if (is_fw_downloading(nxpdev)) > > - return count; > > - bt_dev_err(nxpdev->hdev, "Frame reassembly failed (%d)", err); > > + if (!is_fw_downloading(nxpdev)) > > + bt_dev_err(nxpdev->hdev, "Frame reassembly failed (%d)", err); > > nxpdev->rx_skb = NULL; > > Is this NULLing not needed in the good case? NULLing in the good case would be a bug, in addition to that NULLing is not needed at all even in the bad case and it will be removed in the last patch, as a cleanup. Here I just maintained the existing logic. > > - return err; > > + return count; > > Should you return 0? I don't know, maybe not My reasoning is that we have some corrupted data, so we should just use it all and maybe we'll get something valid at a later point, this is what was already done before this change in the is_fw_downloading() branch. In my specific case it makes no difference, it will never recover from this state. Any other opinion? > but you should document it in the commit log. Ack Francesco