Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3347575iob; Mon, 16 May 2022 20:14:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyT/FdktDWMtWiT6Ooj8aNLO5U6is3n4AC/8vU+PJ0uRzW/9vAFdG5pOokHGdw2T69GRMAM X-Received: by 2002:a17:903:1c7:b0:161:9d6f:376a with SMTP id e7-20020a17090301c700b001619d6f376amr3285964plh.147.1652757297141; Mon, 16 May 2022 20:14:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652757297; cv=none; d=google.com; s=arc-20160816; b=YpFaKgug0PQhDIPpBemgpaa0qPFderP9ZOeCDDfZFqGnkNWa3epLakMOFkh7it0/a5 zk7AgQfdQ3U4NWIiBgqksnoheBBL2KLQBt41kQFCAxQK6jZY0f7LdyJOHBeH6Gq1rzU1 xHiwvt+K8NuGaKOigSh64xfr2GzOhjdIMx5gjhydWfg9UJJ7DZHuH/ZR9Y+LpwXV2W9F OPdCVarUW+0o2OlK0dsnBcxq5T+e5ZVT+GeO4zsQAH8JbPdfwrYJG/ZsgWaDZgW0ok1a tWQbr6kV0MafEvROBQq0RrhV6ssWV+cElPn4YcM3l1DPxWilOMa+4HeHJL2c1kTWhVpK yCeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=i9PJvhEX8P9EwLto+E+6JAbwn0v8MnYujSttxKDDDe0=; b=eMFyP3WBxLwqLKRLU6s+ik+84SZv8+b7OMFSw0DRC7SadjUKBhqs2GFBJNWFJTbm9G oqtsJr039xwRpKPGtLpQRBt2oYjthWdJhYFZ28BwqgsxrDMqIiCPUeOoBLX/E1fn/xfe ruYKnKTcl9p0EZIIVxN991EPpBh/crvm3j4Eh9FJTv/BQsDqhbjtJ2HmtHJUoCw0cQUT XsMSH1pnAOMPVjNDYKQuFAwD5CqxAcP8jDbDbvjAe3dGFNoCVCNOJvYMGSb14cH9wiWt Ugcm0AZpqZCkPN2dGeHd3WspDr8eLlbUrKv+/40XOU9glCzMOu/kUkKl4jKNoBrJdQFV xypA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gyHPkeZ1; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gw19-20020a17090b0a5300b001d653c53a03si1491029pjb.11.2022.05.16.20.14.46; Mon, 16 May 2022 20:14:57 -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=@gmail.com header.s=20210112 header.b=gyHPkeZ1; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241117AbiEPJXR (ORCPT + 99 others); Mon, 16 May 2022 05:23:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239350AbiEPJXM (ORCPT ); Mon, 16 May 2022 05:23:12 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD4FADF62 for ; Mon, 16 May 2022 02:23:09 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id q4so13850988plr.11 for ; Mon, 16 May 2022 02:23:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=i9PJvhEX8P9EwLto+E+6JAbwn0v8MnYujSttxKDDDe0=; b=gyHPkeZ1dgLRtMeRxdorI5w1fdjB4J3YmtzSTmkYFa8IUSpX0xpHYUz6U+4twmmwTl oDF+u4ROFIAMLF6MCty0pjThUiK0gdwlkvt9L5SPTiudgVu2t/wlq0yMl13jv1blq2q6 oOe+INfi9zlAWSr541+QEzyXk65XY5HikjzRrzPZIWu+QPlPxHIdQPAkWuKMACxu4NZY GKHqQyzG9iUvZM2Mor6GFnuymkeDbA/4SWZicX8d21pEIEP/2Zi0IaWQd0F2H59XSl/F OSQwkKKFUA2S3Vs7p2xfbEAw/PjGzSA4GCif8M8MVTJLhEriGYPEAqcEoRVyTdOrJPzD 6p9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=i9PJvhEX8P9EwLto+E+6JAbwn0v8MnYujSttxKDDDe0=; b=S/g6UQo7cNfioIaW5bvaG5DtZZ2kF4mLA7uR40Exwa9xSE6+HoXrh7499SOcks9NLg EyWe9U+Pju6dvsCXMfz9cx85auCgTn3dVDYwoFKJU5w8pYRAAAwjiYORhu3PkARwe+ba 4Pv3KEgg4hii1sz7/eiDRZw9PxC1jRG5LSOhbRwZm+YSJ70dGtltBgPhIA5oqS5pIC0E X3a6B7D2GGH8tpzizk2S2PvDSTzWfMJRmN7X6VFuanRoR+ejCq7EXLnDhlT45eC3HN3r 9wTw0GWcgMZPr6qB75Ku7P3OvrNiaINuH/1qEU1+QI97gycxL0h5sYwOJ3ypnNBz5iRv AZsw== X-Gm-Message-State: AOAM5309WhhL7Jviy0RTMoenw8FxODuFYkUj1yAKcWMuKFW8ZW7clYCO RPVdjDlz76epX/SpzSv/9/k= X-Received: by 2002:a17:902:f60e:b0:158:5c4d:d9b0 with SMTP id n14-20020a170902f60e00b001585c4dd9b0mr16947949plg.63.1652692989318; Mon, 16 May 2022 02:23:09 -0700 (PDT) Received: from localhost ([152.70.90.187]) by smtp.gmail.com with ESMTPSA id l9-20020a17090aaa8900b001dd11e4b927sm8008101pjq.39.2022.05.16.02.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 02:23:09 -0700 (PDT) Date: Mon, 16 May 2022 17:23:05 +0800 From: Wang Cheng To: dan.carpenter@oracle.com, paskripkin@gmail.com Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/3] staging: rtl8712: add error handler in r8712_usbctrl_vendorreq() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 When 'status' returned from usb_control_msg() is not equal to 'len', that usb_control_msg() is on partial failure, r8712_usbctrl_vendorreq() will treat partial reads as success. Signed-off-by: Wang Cheng --- drivers/staging/rtl8712/usb_ops_linux.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index f984a5ab2c6f..b2181e1e2d38 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -495,14 +495,21 @@ int r8712_usbctrl_vendorreq(struct intf_priv *pintfpriv, u8 request, u16 value, } status = usb_control_msg(udev, pipe, request, reqtype, value, index, pIo_buf, len, 500); - if (status > 0) { /* Success this control transfer. */ - if (requesttype == 0x01) { - /* For Control read transfer, we have to copy the read - * data from pIo_buf to pdata. - */ - memcpy(pdata, pIo_buf, status); - } + if (status < 0) + goto free; + if (status != len) { + status = -EREMOTEIO; + goto free; + } + /* Success this control transfer. */ + if (requesttype == 0x01) { + /* For Control read transfer, we have to copy the read + * data from pIo_buf to pdata. + */ + memcpy(pdata, pIo_buf, status); } + +free: kfree(palloc_buf); return status; } -- 2.33.1