Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp535888pxb; Sat, 21 Aug 2021 09:55:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6rFizNZI1FfyrdkevX5jILuSdXuBUgclMvGrdItm1hhvxgYguDLd4mGNmivZAQNBl0RH+ X-Received: by 2002:a17:906:585a:: with SMTP id h26mr27830248ejs.31.1629564934385; Sat, 21 Aug 2021 09:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629564934; cv=none; d=google.com; s=arc-20160816; b=X6P9Z0CTHSmNkDkLD2j5YUAF/hOPnZciGrEUkEoS7dqMeYXOKPq0alhw3zytJaWEqC Zvv34uYddCyaKlzR78FD5PBI1Neoqqo3y1+aKVKROdEvTIVdhl+W3x3kzoyq3z1BLlp6 ZcoxNqXbjlgrMZoCV2h7GBr3iwTKYG4tTR2Gca0yOoCsbt1cY72LzyD8MTBFmWlHwKBD naGAin008uR9im7/icnHmiUjxl/xO29DS14YM6siMwgbyI2FLdlBBTZWdI1bvwPRPNOy GPb2k2OrOzbdTfIir+lqyvpRUF13vBxRQGeylwICtzO2pq4kmzzCeUQLQzlbpqAiPYVa xiGQ== 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; bh=w+jhdcb5t0qZSSbrIuQVzWp/oTl2kRnZvABWErqVAtg=; b=tMlHbXLkt2sF4Mvu/Qi9pnVBmQ/iV0TEcwev0SW3QqXrU8QJH9Hu15KcAwg6ivgPJV hGnux204DhMU1VNcNCQhdUjTFHDnDBkjyTxgVXrKWqgdO9sZJUg6t3nuZroXatzDyzyq YUAHhReFz3bz8dQXUUnCW/Xskl2jL6oEITXW0qmv0EraLPiFZWSH1th0MpwEyw1V0E7R ZSf08V+ttpDem/b4BogiqQuM5Tejf2A2hwA70OEHaWHSXIZKIEf9uQS5cvzp14xBHrw8 I8QMSUhcgpvjb2NsxlrVcM3rmmoxPjq0S4uwkyeu1+bi48dNdmM+XpooD7vNtKAJYLAv tU1A== ARC-Authentication-Results: i=1; mx.google.com; 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 qf40si3057974ejc.1.2021.08.21.09.55.02; Sat, 21 Aug 2021 09:55:34 -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; 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 S234937AbhHUQuy (ORCPT + 99 others); Sat, 21 Aug 2021 12:50:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231132AbhHUQun (ORCPT ); Sat, 21 Aug 2021 12:50:43 -0400 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81EC0C06175F for ; Sat, 21 Aug 2021 09:50:03 -0700 (PDT) Received: from dslb-178-004-175-162.178.004.pools.vodafone-ip.de ([178.4.175.162] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1mHUBz-0002Ch-Ew; Sat, 21 Aug 2021 18:49:59 +0200 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Dan Carpenter , Michael Straube , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 08/10] staging: r8188eu: clean up the usb_writeN Date: Sat, 21 Aug 2021 18:48:57 +0200 Message-Id: <20210821164859.4351-8-martin@kaiser.cx> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210821164859.4351-1-martin@kaiser.cx> References: <20210821164859.4351-1-martin@kaiser.cx> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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