Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1209006pxb; Sun, 22 Aug 2021 09:10:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwC4238mEDMbA17EmcT5nuiidcIjIvlfhhq/sV98sgZeMmo5NsicRVn0D13teiM0gAmO63g X-Received: by 2002:a17:907:1b1b:: with SMTP id mp27mr30931578ejc.538.1629648651808; Sun, 22 Aug 2021 09:10:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629648651; cv=none; d=google.com; s=arc-20160816; b=Eo30PiXr+D7pXv9KD+tFquSfMOmfe9ZZ40z1VsC1UtzAjpjsdfWZtSVjzTx1fTOuI4 HahdFwEeUwYQdfdOZ05i036vBAF5NldkiDkPHN0I8nlY+yQjuz1PM6J/vg5iz1/0zeYd JhiNmJUPk9cMYcGY/4cz8elA83ygMFdOU2yn/HfWDvrkQqwBSqXcKWuB8k0GFNEo+TKg 0sDoshum7VPp0MxsxF4NtH6Yfjq7u1I18wgkhEYNyFoa6PlgPp/u3UTlTfaclfknSXrn SJeYgSYpOwliobgRsmQ2y1126RF8JAE9no9/3hlfXhYTJ/iPByg01ZumOzEeR9iZOxoe ajDA== 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=mZkd/qClZ6EIptZd3qcKV9Zn8Vt63Fe539Wcquo0PfM=; b=fsFBb2LL3NxUmGolb9SwgTTpzNBuqYuZeBFIegAwbK7SGD5PuB7O7jLpIjk1y3NCnz zLTZ1jZwvyvYznJnj/U1Yod1RanJIfC8RccyJAjOfnURhYsfbE4SxiPFyn9CMAitnOu+ Xll5WrDbEX+AxnnMVp03zaYGYekZRJSmjVlNxSpcrNKfWd5T62vH+Wq9G2jPsN+czR9F udd7DW+r7dlCOtIcqQCn0WjKcNuS6xsojYamQeNtiwxfjp//zSrFc/DwaOCqQXjIN9h3 ktsF9UqKvpHRAUdb7pRDUl9SUvyxTyhVU0l5ra8gL9NVfFGfzIAatHSeIXbAPctVfAUm HbFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n7ZRUsbx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v4si14496602edj.103.2021.08.22.09.10.27; Sun, 22 Aug 2021 09:10:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n7ZRUsbx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231513AbhHVQDy (ORCPT + 99 others); Sun, 22 Aug 2021 12:03:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbhHVQDw (ORCPT ); Sun, 22 Aug 2021 12:03:52 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3A83C061575 for ; Sun, 22 Aug 2021 09:03:10 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id g21so22177827edw.4 for ; Sun, 22 Aug 2021 09:03:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mZkd/qClZ6EIptZd3qcKV9Zn8Vt63Fe539Wcquo0PfM=; b=n7ZRUsbxJUMYDi99aBmk8yA8tUhzKJa3AFfHOLZkcnaWhJbb0mup3a6KYzkE8GpIuK COfH2QMVTodnElA0LDrBfA3WSh3Bu3yCJLifvupGGMCWzTwj26QF/1o6X8o+hWAA1y23 DgNkAeQ4a/tp9A8xiefaVZiWxeBPN/jnBU581lt0yyetk2KFmuAr9ZvGlQU3PVjh94NW AjB75Rf0RJ/ATuFUr3hdDTK5y1en02dyG2wZqLEMK3TFD78mY5i62SAyAi3tU7xiYXz8 n/fME/BwDlSgYNUO/vG2DXIGPuiCFl8/Sb4f/Ln2NXM+RR8BF90pnihEkpumeY6qqQWB 5cIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mZkd/qClZ6EIptZd3qcKV9Zn8Vt63Fe539Wcquo0PfM=; b=j5osG1yVPQOD7nYPTFO/whx6+sXVLe5tWoIX5yp0hqyxZlxqz9POgXVlTPIddMGafU fpvSqrZHQXe6gdnq4F6rLT7QpwbfLh7lJp5Ew9weLzV388ip18IDjgj4Y+lVe/A9JQuA 37qM9+61pAHSE3lZ+st/ubggncGGoKEcl+JLuBNyt8LtrEAapQP+zhKQGMXYbGKfKqK/ X2g6mV32QMcOt9LhP6fvQBMgJmixEkOB7RrCSqsRYdDoYwkaZxlgufx1rjPxsY5KqoQ/ 4WKp7YGOi2E7fKfVcluwp7XuBwxYV6vqSf+T8M61xF1XrLUlXphuXrh9NQsoagSChgVX PWFA== X-Gm-Message-State: AOAM533cnIgg95IKwHx0xZG5V99fzCM7E3RKAop7QEJ2CquioimO41rJ /v+pgiyamiieFXtAzt08xMs= X-Received: by 2002:a05:6402:b64:: with SMTP id cb4mr32602209edb.49.1629648189323; Sun, 22 Aug 2021 09:03:09 -0700 (PDT) Received: from localhost.localdomain (host-79-22-100-164.retail.telecomitalia.it. [79.22.100.164]) by smtp.gmail.com with ESMTPSA id ec49sm7435021edb.54.2021.08.22.09.03.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Aug 2021 09:03:08 -0700 (PDT) From: "Fabio M. De Francesco" To: Greg KH , Pavel Skripkin Cc: Larry.Finger@lwfinger.net, phil@philpotter.co.uk, straube.linux@gmail.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: Re: [PATCH RFC 0/3] staging: r8188eu: avoid uninit value bugs Date: Sun, 22 Aug 2021 18:03:07 +0200 Message-ID: <23968040.bvS6LFdsLj@localhost.localdomain> In-Reply-To: <6182ed46-d79d-7f66-c7c0-096486410b4d@gmail.com> References: <2244219.zNr1yEsLHP@localhost.localdomain> <6182ed46-d79d-7f66-c7c0-096486410b4d@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sunday, August 22, 2021 3:31:31 PM CEST Pavel Skripkin wrote: > On 8/22/21 4:21 PM, Fabio M. De Francesco wrote: > > On Sunday, August 22, 2021 2:39:34 PM CEST Greg KH wrote: > >> On Sun, Aug 22, 2021 at 03:10:56PM +0300, Pavel Skripkin wrote: > >> > On 8/22/21 1:59 PM, Fabio M. De Francesco wrote: > >> > > On Sunday, August 22, 2021 12:09:29 PM CEST Pavel Skripkin wrote: > > [...] > >> > > So, it's up to the callers to test if (!_rtw_read*()) and then act > >> > > accordingly. If they get 0 they should know how to handle the errors. > >> > > >> > Yes, but _rtw_read*() == 0 indicates 2 states: > >> > 1. Error on transfer side > >> > 2. Actual register value is 0 > >> > >> That's not a good design, it should be fixed. Note there is the new > >> usb_control_msg_recv() function which should probably be used instead > >> here, to prevent this problem from happening. > > > > I think that no functions should return 0 for signaling FAILURE. If I'm not > > wrong, the kernel quite always prefers to return 0 on SUCCESS and <0 on > > FAILURE. Why don't you just fix this? > > > That's what I've done in v2. All rtw_read* family will have following > prototype in v2: > > int __must_check _rtw_read8(struct adapter *adapter, u32 addr, u8 *data); > > Was it your idea, or you were talking about different approach? > > With regards, > Pavel Skripkin Pavel, Yes, it is correct. However, after that I had time to look at the calls chain and understand what each function does and then I saw that my initial proposal should be made along with another one... The calls chain is: (1) _rtw_read8() <--- (returns the data read from next function in chain) (no errors returned, see possible fix in next function) (2) usb_read8() <--- (returns the data read from next function in chain) (_data_may_be_unitialised_, no errors returned) (possible fix: from "u8 data"; to "char data = -1;") (3) usbctrl_vendorreq() <---- (returns data read from next function in chain) (data is always a valid pointer saved to third argument) (if it fails, the third argument is unchanged because it still has the address of the "data" argument given by the caller) (4) usb_control_msg() <---- (it always returns how many bytes read or valid error codes) (it _never_ returns 0: either positive or negative values) I have not yet looked at the usb_control_msg_recv() which Greg talked about. To summarize: in function (2) "u8 data" should become "char data = -1;". Regards, Fabio P.S.: I was about to send this message while I see that you sent v2. Since I've already have this response to your question I send it and soon after I'm going to read your v2 patches.