Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2733605ybb; Sun, 12 Apr 2020 13:31:03 -0700 (PDT) X-Google-Smtp-Source: APiQypLOh/pVIFSkWAJ1RmWkZmNKikF0mpBeBGgPVNcyXRlC/+laQL4RHfV1zNC8b49hHefp6S0w X-Received: by 2002:a37:4981:: with SMTP id w123mr7458605qka.497.1586723463660; Sun, 12 Apr 2020 13:31:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586723463; cv=none; d=google.com; s=arc-20160816; b=yF4rN/lV40PvU23A1ugwjAvOXK2vH36f/sP9axiCnKJWXQmSCG9W7FlgMRDrr841Cs z+9PFuqQsZYoab6bSO0LjuOhvcAIU3LZRDHc3pZE6jHsQVSp7481PVcJ6KpHgNYsEaU9 0Cr70m9/PXy1p1ESVXB+xOuQPPEoIdYaT5j6VxIl6TYqtaDjc/os4erMMV2JakYrOBen Bymbzc9S+zEN7b+Mk0nfzBxiQJsgjMqu+GguPxMdYoEVcZoHNmV3Eglj25KhM9635+AM 9bGNgQrPaKOuioEUznvmNIviRaLjM0liJ8ewYvHxI8dYhjBtF5asX6c3fwDF9DQmhOI0 owng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=XqXdwaROdeqIddDJWAnUAB3A8A8bFJlYtL6MGb2s/vw=; b=xjDlBYTC41HMWKWhjoT7n2fenaRfB5HhW1cDgfuMDWUKlq5CObQP6ESloe34HSHi8f 7KL5jg0BdPYDccoZfGy/Z5nj0ZYWyZd0o8P/mDe1860WAQ9nt33eBjlHr8oDMjz2kPJw 5+NKbf9i8d7pA7mrMVGlbAVkboizKUh3joI3a6RHy//oQuOcKfUq79KpKQ5R+6qCpRtx w7KDf8Q/XevlA0Gp1fV7JfpYhEXc7KWIuS5+WzrQyNz/KhV36VQtlrVfWRqBYaXn3qg5 PgL4vz26IOQAvJtsX96GnwARcSR6f6OBixYpNix1/lgaDUqrxo+7FE2Cevqcwsph/TR+ W1Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uIouA633; spf=neutral (google.com: 209.132.180.67 is neither permitted nor denied by best guess record for domain of linux-kernel-owner@vger.kernel.org) 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 ([209.132.180.67]) by mx.google.com with ESMTP id z36si4732715qtb.4.2020.04.12.13.30.21; Sun, 12 Apr 2020 13:31:03 -0700 (PDT) Received-SPF: neutral (google.com: 209.132.180.67 is neither permitted nor denied by best guess record for domain of linux-kernel-owner@vger.kernel.org) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uIouA633; spf=neutral (google.com: 209.132.180.67 is neither permitted nor denied by best guess record for domain of linux-kernel-owner@vger.kernel.org) 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 S1727400AbgDLRkI (ORCPT + 99 others); Sun, 12 Apr 2020 13:40:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.18]:35756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727221AbgDLRkH (ORCPT ); Sun, 12 Apr 2020 13:40:07 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80E21C0A3BF1 for ; Sun, 12 Apr 2020 10:33:05 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id m8so6699911lji.1 for ; Sun, 12 Apr 2020 10:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XqXdwaROdeqIddDJWAnUAB3A8A8bFJlYtL6MGb2s/vw=; b=uIouA633MGmMPi38mufwLK2Pn6s3EErihVLplll0QAPlxnIPv19I+PUjrJlhOYCf6R IzKKGWasvrHhPYFn6tMNt9qyL5RLjHDfMstd76qsGvVYjapANY1gSM7crTCkTxPgsZNN wKGLiMU9FOnVDy7nFcq2cumSDj5DSeNyKFRu5qkV9N+KSQMMrDJZ2weAQ+5CDb1ucbd3 f/buDeZ/Z7hDIUrY6MYm08fimVD/HL6iqGZ17szK+RvB77aLd9uxT/1si79RFGkYbwxD mLMYoY4UZaIJ6rGd/8gkWtTlrWzI/yPngkY93rP0CLvB51eXvWVVoeoZE3e0OhlaL0XC 581Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XqXdwaROdeqIddDJWAnUAB3A8A8bFJlYtL6MGb2s/vw=; b=HnMpNA/MVCBH3ZrYxW0+qhYghbdNcPuie95ax7qcr81ftcruqhcvhuvUUSWFIw/jdU bByhdlDB24ZEJDx7yEhfC0Y4zWzixqLGUaiUzlWySnEqgE99CThsxRlM0BFCdNuws01P RnLxL39Gks7xYJJ+DR+3V9BaFe0/H5jE5A8W3YLlYMKo4rF0CMXjlmRK5TG1KAQmq1zg oMRCnExLaBgm9xBudj+DKrbOTyW9oWwPtWPCNgu3Smm+aCe3eTvf8pQDaPaNoDS+ub9N UvT2DdNWPcFBFBV4klwV6Ptk8d3bo28ZsnF7qvzT11jA6PkMJWYUdFQFsknLVDQOJAo7 O55A== X-Gm-Message-State: AGi0Puavhzwrh/c3LtEMUP9UXAfRq2guTwG4vzcS8E/VYK/t2nSf69Sf GgMaDFuoV5E7aQ+BGlkd+VTMI97Q X-Received: by 2002:a2e:9b07:: with SMTP id u7mr8343800lji.110.1586712783851; Sun, 12 Apr 2020 10:33:03 -0700 (PDT) Received: from alpha (84.188.smarthome.spb.ru. [80.249.188.84]) by smtp.gmail.com with ESMTPSA id 28sm6398249lfr.7.2020.04.12.10.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Apr 2020 10:33:03 -0700 (PDT) Received: (nullmailer pid 846531 invoked by uid 1000); Sun, 12 Apr 2020 17:37:37 -0000 From: Ivan Safonov To: Larry Finger Cc: Greg Kroah-Hartman , Michael Straube , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Ivan Safonov Subject: [PATCH] staging: r8188eu: replace rtw_malloc/copy_from_user sequence with memdup_user Date: Sun, 12 Apr 2020 20:37:16 +0300 Message-Id: <20200412173716.846469-1-insafonov@gmail.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org memdup_user is shorter and expressively. Signed-off-by: Ivan Safonov --- .../staging/rtl8188eu/os_dep/ioctl_linux.c | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 0aff01bb69c3..d5968ef9f43d 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -2012,14 +2012,9 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) if (!p->pointer || p->length != sizeof(struct ieee_param)) return -EINVAL; - param = (struct ieee_param *)rtw_malloc(p->length); - if (!param) - return -ENOMEM; - - if (copy_from_user(param, p->pointer, p->length)) { - kfree(param); - return -EFAULT; - } + param = memdup_user(p->pointer, p->length); + if (IS_ERR(param)) + return PTR_ERR(param); switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: @@ -2789,14 +2784,9 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) if (!p->pointer || p->length != sizeof(struct ieee_param)) return -EINVAL; - param = (struct ieee_param *)rtw_malloc(p->length); - if (!param) - return -ENOMEM; - - if (copy_from_user(param, p->pointer, p->length)) { - kfree(param); - return -EFAULT; - } + param = memdup_user(p->pointer, p->length); + if (IS_ERR(param)) + return PTR_ERR(param); switch (param->cmd) { case RTL871X_HOSTAPD_FLUSH: -- 2.24.1