From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 369AFC4338F for ; Tue, 24 Aug 2021 12:09:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C32461248 for ; Tue, 24 Aug 2021 12:09:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237083AbhHXMKF (ORCPT ); Tue, 24 Aug 2021 08:10:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234787AbhHXMJ7 (ORCPT ); Tue, 24 Aug 2021 08:09:59 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B99A8C061757 for ; Tue, 24 Aug 2021 05:09:15 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id r9so45094798lfn.3 for ; Tue, 24 Aug 2021 05:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=7PcdMnGwD/TVBDMI0hdvsoYsiNHwhw3N+WJOyBZilh4=; b=NFwLL1O0h2SMOf5CPHyCc52ibh3534uLa/004eAEb3oAeOBTqQ9cKa4gDk9qYGlXxg Z72YxwrEp7gCvXky5oxDBrH2dUgqbAf5MLk/vBPER9p/fPpqXgZV1+2OFCOLd7s4m7Cd ZOxFJ0pbVpEmrdurSG3xLVtd4km5YrBWyYQEvOsO0jHFGAMGvkEWHFpkuPVSjkrloQvH tizxFyE9Ftttk2lycn/N2/ozS2fKrt0nQZKf+quc33jYO2hbeQYqAQ++h9rdOV+ieqda 7Quj3KWlSlNhOYl6frhzvLlV45YMnLrAG316i4cIFwzsPOXH8fu9c99PiSF4ITm5WqHu Nkdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=7PcdMnGwD/TVBDMI0hdvsoYsiNHwhw3N+WJOyBZilh4=; b=iJ+k1S53VkTdI+bJ6FZQMy+wuVVTcpEGQBazHPTp4ZLU3kD48OXmyk5Xm2binrZfma kmFUvJTcEMpYx0jLSzI7AR5CWMk6tc9QS17Cbxrm2cidv3gcXnqfCaCjbmF5QuJ/DpyL Hz8kYeNiOyODhJFRgvN7RafBsY/Pn8E3EgTD2k65s5zwal7m/odRJLPPDYdHmVDaj5nw rTvYp3Mr8l2KsKYR+q9lDC3mxjkl7XUpjMF0zNk0dPdfFofiFcQXmSHoJsSWz4sHgnBF UiIqxN8Ji64BlOvsaBi0h//AAOSv1k14nNzsl+2VSouIGz2/yVcnvpqofaMjY91VNeiA 5PCQ== X-Gm-Message-State: AOAM53369VbJzUkw1VY1sV9GSC0rJaFkkgVKDsLMRD42p+lqeQ89zLf1 Is9bRjgTesdKmUjRX7Q1bqb2mmm9EPjMog== X-Google-Smtp-Source: ABdhPJyY345P53Z28nzO2jWCu6n4NOM7PhVobj4nHXVuC8nw9Jbxxqd1zL4sDPM2n6G0NB8Avquzeg== X-Received: by 2002:a19:740d:: with SMTP id v13mr12925642lfe.655.1629806953845; Tue, 24 Aug 2021 05:09:13 -0700 (PDT) Received: from [192.168.1.11] ([46.235.66.127]) by smtp.gmail.com with ESMTPSA id e8sm1780825ljj.132.2021.08.24.05.09.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Aug 2021 05:09:10 -0700 (PDT) Subject: Re: [PATCH 1/2] staging: r8188eu: Use usb_control_msg_recv/send() in usbctrl_vendorreq() To: "Fabio M. De Francesco" , Larry Finger , Phillip Potter , Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org References: <20210823223751.25104-1-fmdefrancesco@gmail.com> <3198276.4iybWabFxt@localhost.localdomain> <6601006.JhxPbakEoc@localhost.localdomain> From: Pavel Skripkin Message-ID: <99d69811-deff-d346-634e-20e9fdead7c8@gmail.com> Date: Tue, 24 Aug 2021 15:09:10 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <6601006.JhxPbakEoc@localhost.localdomain> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/24/21 3:01 PM, Fabio M. De Francesco wrote: > On Tuesday, August 24, 2021 1:07:46 PM CEST Pavel Skripkin wrote: >> >> Btw, not related to your patch, but I start think, that this check: >> >> >> if (!pIo_buf) { >> DBG_88E("[%s] pIo_buf == NULL\n", __func__); >> status = -ENOMEM; >> goto release_mutex; >> } >> >> Should be wrapped as >> >> if (WARN_ON(unlikely(!pIo_buf)) { >> ... >> } >> >> Since usb_vendor_req_buf is initialized in ->probe() and I can't see >> possible calltrace, which can cause zeroing this pointer. > > I see that usb_vendor_req_buf is initialized in rtw_init_intf_priv(). It depends on a > kzalloc() success on allocating memory. Obviously it could fail to allocate. If it fails, > rtw_init_intf_priv() returns _FAIL to its caller(s) (whichever they are - I didn't go too > deep in understanding the possible calls chains). > Call chain is the most interesting part here :) rtw_drv_init() <-- probe() usb_dvobj_init() rtw_init_intf_priv() If kzalloc fails, then whole ->probe() routine fails, i.e device will be disconnected. There is no read() calls before rtw_init_intf_priv(), so if kzalloc() call was successful, there is no way how usb_vendor_req_buf can be NULL, since read() can happen only in case of successfully connected device. Anyway, it can be NULL in case of out-of-bound write or smth else, but there is no explicit usb_alloc_vendor_req_buf = NULL in this driver. We should complain about completely wrong driver behavior, IMO :) Does it make sense? With regards, Pavel Skripkin