Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp565323pxb; Sat, 21 Aug 2021 10:50:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKMGvYOwdVtmqpfYz6Ac6nSGr0Uh87/r3Ba7/Xb6eb72v626PU32evXcTThZ7ftZTC/1WK X-Received: by 2002:a92:de4b:: with SMTP id e11mr17481808ilr.22.1629568210360; Sat, 21 Aug 2021 10:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629568210; cv=none; d=google.com; s=arc-20160816; b=wcD3ImAyZSw2a7A6qfrgMAqzZTUa7Eln88sw8tn0/y02JZN/2o7gNOWJPuf1JeSuQP 7x0QKFTe944gN2wmOxy8GczYQeKKd7H1hiy6Y+y/JOiZ507g/FkJ99cir/R3wehaR7VF 4f8QRjUf/aLHPxqxWhUvCGwrZCdw9s6gI+Cau1UV5hSthTOIZjCQF8PvefV+lN6X0bE4 lbCsIIbN4pDsHriYsAwR7sIlRjAl9eAfmoifZqhd90JRnfjg7UmS4+bogcVc8Bw91fki MDKp+E5zM7scXhU08jQ9zJppvjqOHnVu1ql/63mRfD14F1B+sDePHaVDKVLsjpQlrKBw FYYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=dp139urNDxO4JTlPsXpj0kyL07J5UAiGj94dEKj6njg=; b=VO96QJ2FckUCDmHqpB6heFkmT54ie3mubDMW29lMU655AfDzL5mw9ctgvIajt/8lSj NV50fDg0n32gFDxFgYeZYiesFEd9t/8EBlnDrt9vI1nuQjMXEH4ku+I/1MJ1GTn6AWCP fyFJiKPSdKXiFcd0MLp+OXDcesNOy6jhO2qoscz94n1ct1IN8C8jZm7CwFEVGcRnuCAB 0bFAra7fLO3/M2j5HP11yMimVqbr+dSIlS/gVKPY8rfpOAoIzq4xS+mrLZJTRbCzPzfX 4rYB5WGBpyDiVtSaxaXjh66FJ9Aa4i1ZQ5/CbRhn0Z3OWqV0fBXW9yX0defqrlGtKtYC f+Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@philpotter-co-uk.20150623.gappssmtp.com header.s=20150623 header.b=gYP3msuC; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t10si3691135ilu.150.2021.08.21.10.49.59; Sat, 21 Aug 2021 10:50:10 -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=@philpotter-co-uk.20150623.gappssmtp.com header.s=20150623 header.b=gYP3msuC; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234621AbhHURr4 (ORCPT + 99 others); Sat, 21 Aug 2021 13:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232462AbhHURrz (ORCPT ); Sat, 21 Aug 2021 13:47:55 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DB2BC061575 for ; Sat, 21 Aug 2021 10:47:16 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id n12so7786596plf.4 for ; Sat, 21 Aug 2021 10:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philpotter-co-uk.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dp139urNDxO4JTlPsXpj0kyL07J5UAiGj94dEKj6njg=; b=gYP3msuCsJfbPlYUKun+IfeDkptAAhdgN9OaIizYT0MZ3LV4l6g29qvogUOKmtO8+k koODEopMSx0JERsR18i8WFduTgbPTk6mkDnl59y9lbf43eSOrqUA2AzNfA74xehNqwx0 NiRZ+t5YA18yHKBIcZ3H4PVKRImO1vPHwLkb72KEB4sLvkQjC6cfMh1l8TyymaRoCTUv /oWptnjpCr5Tn+L7W8n/kj3oHGjk0YzzDlJ2RnMQxCggo5JkpDRnz7gq7FwgUYGGEeLk b6LWnXrpW7JxmrS/8gAS+xFvSU1jiUuDA+iWTdQq7Qsg7X3gkR0EG+vtXdfksZJEqqXi SYPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dp139urNDxO4JTlPsXpj0kyL07J5UAiGj94dEKj6njg=; b=cIwrtJWt9vEVWGG35uRkFVTVzmEGEGi3VCb49L1r37rPcOvEiquVZgtw9QUnzt4Bc6 5nLw0j2d/CfvgBiWr/7JLZ9ETd3/juIPvJnN7eJJ5brJGKQk4pQNrcC/JacMRPxNc99U SNW7bmdZLBesd7/kR33d6Xv8xk/5e8PyRsNM3NHUN5oZR+yUSAFBiMx93G9KA5o9QWs5 zX3CsGB768nC25ZFNdxLE4Dzkq2qpiukKVYv1NMDsA1TbTwNeJtkN2LwV9EGKEvbKZ/4 Dqf4eQBwxYXfF+8dneHXvzQEUBZ33CGJVw2/WXuzIME9uYpC/4yVqb6yRN2b0eju/YYC EA9A== X-Gm-Message-State: AOAM5327e8P3/YKBmCXpU5HL19+b0isp+vWM1LQHEEJY/gY4KqP5YjgG OMzAppvbyvKswC72pU1J/lTM0uMnBQlDVxkr/P5liw== X-Received: by 2002:a17:902:f704:b029:11a:cdee:490 with SMTP id h4-20020a170902f704b029011acdee0490mr21546731plo.37.1629568035580; Sat, 21 Aug 2021 10:47:15 -0700 (PDT) MIME-Version: 1.0 References: <20210821164859.4351-1-martin@kaiser.cx> <20210821164859.4351-8-martin@kaiser.cx> In-Reply-To: <20210821164859.4351-8-martin@kaiser.cx> From: Phillip Potter Date: Sat, 21 Aug 2021 18:47:04 +0100 Message-ID: Subject: Re: [PATCH 08/10] staging: r8188eu: clean up the usb_writeN To: Martin Kaiser Cc: Greg Kroah-Hartman , Larry Finger , Dan Carpenter , Michael Straube , linux-staging@lists.linux.dev, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 21 Aug 2021 at 17:50, Martin Kaiser wrote: > > Remove unnecessary variables, check the length. > > Signed-off-by: Martin Kaiser > --- > drivers/staging/r8188eu/hal/usb_ops_linux.c | 15 +++++---------- > 1 file changed, 5 insertions(+), 10 deletions(-) > > diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c > index e01f1ac19596..5408383ccec3 100644 > --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c > +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c > @@ -151,20 +151,15 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) > > static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) > { > - u16 wvalue; > - u16 len; > + u16 wvalue = (u16)(addr & 0x0000ffff); > u8 buf[VENDOR_CMD_MAX_DATA_LEN] = {0}; > - int ret; > - > > + if (length > VENDOR_CMD_MAX_DATA_LEN) > + return -EINVAL; > > - wvalue = (u16)(addr & 0x0000ffff); > - len = length; > - memcpy(buf, pdata, len); > + memcpy(buf, pdata, length); > > - ret = usbctrl_vendorreq(pintfhdl, wvalue, buf, len, REALTEK_USB_VENQT_WRITE); > - > - return ret; > + return usbctrl_vendorreq(pintfhdl, wvalue, buf, (length & 0xffff), REALTEK_USB_VENQT_WRITE); > } > > static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbuf) > -- > 2.20.1 > Acked-by: Phillip Potter Regards, Phil