Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1117777pxb; Sun, 22 Aug 2021 06:27:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx8A+7APTaMXtJt6h3hZTelto3Q44j2jyt2qRtvUM5oHm6hVpDwra3pXS60y4c6xrmGNWa X-Received: by 2002:a17:906:76c1:: with SMTP id q1mr31585584ejn.156.1629638860253; Sun, 22 Aug 2021 06:27:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629638860; cv=none; d=google.com; s=arc-20160816; b=Eo39bezDjW/1Ozv0S9310NF+YngmXYF+x5iHWVWyHhVTDYx+DAEy9FJkZF2fwFyUZb 3YkcsdgybssGjiLfj9RdFNE2pd/crE3rkqpMbKcI0rmhQnS8+D9xq9G+Gji1zP5YBdph EWp1bHAj0S5GxVUxmgD8oL4wG4GPEsSQ/9CH5RRo0f5v4fPHCXydGdkCH2Kyk4g2Pw2F MedhApBpIEJLVk8SUKuPdQ+qhENo2TVGahoU7wcZislW7SWyCqCXBmesLirTSZhbO1Nx VN8TVvY7pP0HPIrmeiaWczgd/heRJT30fz/UYaZ9KKYkbUJG9eSQVWPwyHsMp6S73k18 Wnjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=kZw4V2Zva7YZ4ZIBobOrnt2elWvFQ0nGG2fMiXvkreg=; b=MaWKCUXTH1d0CptGDwdFq4R1caiedvkO0pLFTnLVYSOvk/JTsNIFTpnS+U+s0oVSl3 pBLhbCLb1AybJxd9g/2yixnZ0VyhAZBt5zMUx3+PhRk/n6MLLUxprv+eIFx8wYkFbVKY 4KG13j1uNh2PQBP4gSW794875AM85F2AHIakRbsjdMvQwER8SlQV6h4H+VjKwLV1qh20 SVo4bIGpnR7ZiceDldfUKWpQjknUFxOVFYTKw/01WkQE2jiF13NLUXHWFYRR4b0UCaXt qSgr0PdVhUuyVrID9HWGQHS1o3NPoRRBt8wmHELnbt0keo5uo25MRrxxUFUahstelT9h Vs8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e9MHF138; 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 cf3si11031197edb.127.2021.08.22.06.27.17; Sun, 22 Aug 2021 06:27:40 -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=e9MHF138; 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 S232241AbhHVN0R (ORCPT + 99 others); Sun, 22 Aug 2021 09:26:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230495AbhHVN0R (ORCPT ); Sun, 22 Aug 2021 09:26:17 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39AE6C061575 for ; Sun, 22 Aug 2021 06:25:36 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id u1so8841281wmm.0 for ; Sun, 22 Aug 2021 06:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=kZw4V2Zva7YZ4ZIBobOrnt2elWvFQ0nGG2fMiXvkreg=; b=e9MHF138iOszSWiu/z/oFHbPB0n6q7aUnWysxNFTpiW0GA0/SR5eQIt5KlXXoiQPhT 6KGTYbb6npHFiiMCwjjA2sNzdOBvnrDPEIFQTG+jyH7eKuFUKBUXE2zaBC1sbiOzMJ23 UtcrQckzLt0P19mZbYZWm9iMqZ/e/1xp/DhhyifO/nKfeiX0OK5YCcVnMaoxr+fkhtMI LJ9M7a03BVa2wkn0sY9ppjg7HYJNiZCSKzaUpyiZAOVA3HaRiZTHwZ2Ej2Q2TEtWDptZ 2lmgarcnDev9X3cuhI+hpBuDIOATfmW101pBYpk59vjwcdbZda0hbRTatIVxczdRwcxk Sq5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kZw4V2Zva7YZ4ZIBobOrnt2elWvFQ0nGG2fMiXvkreg=; b=Px4D8t9rhNJmUyBL/ybbxjdeYAgJY3+gWmPGGE8TgJnZsAyPOJnw43jYmpQZFt/Skq 9wvd6Ii65gEH0ZOxgaLmox6Hvl0N8kVGuYaRBo+KfWz872Dg7AAMN8g8ZRW8IpDD4M7P G9iUzOOidD5RQUduvlH660xAnhPNwykndMl8rHiUnsl1TkmYkYxOklztkmqevTIPIjL6 duDLg5kurgmKymzw0pAXvLAd+rI7c5E934OMX/MLBr0dc40Wt1VmOi6PWCE8OKrAebAL JfrMZbyu747ce8KONOiXEUl/dMX/X14ADm1W/VXxQedbihmtDxe2OP2CBYy+sh0k61bh uaPw== X-Gm-Message-State: AOAM5329MA36KKNm/UtloFF49ETWR6eVnNB6d3HgGh5u9Z3SLkIk/0fN rrX01kja18yeYahEjFuHeAiH9HqOyEw= X-Received: by 2002:a05:600c:4656:: with SMTP id n22mr8006302wmo.74.1629638734921; Sun, 22 Aug 2021 06:25:34 -0700 (PDT) Received: from ?IPv6:2a02:8108:96c0:3b88::687e? ([2a02:8108:96c0:3b88::687e]) by smtp.gmail.com with ESMTPSA id q11sm3747298wrx.85.2021.08.22.06.25.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 Aug 2021 06:25:34 -0700 (PDT) Subject: Re: [PATCH 08/10] staging: r8188eu: clean up the usb_writeN To: Martin Kaiser , Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Dan Carpenter , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org References: <20210821164859.4351-1-martin@kaiser.cx> <20210821164859.4351-8-martin@kaiser.cx> From: Michael Straube Message-ID: <6593f24b-8986-df5f-e2ba-5358360939df@gmail.com> Date: Sun, 22 Aug 2021 15:24:43 +0200 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: <20210821164859.4351-8-martin@kaiser.cx> 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/21/21 6:48 PM, 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); Hi Martin, shouldn't this be memcpy(buf, pdata, (length & 0xffff)); > > - 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) > Regards, Michael