Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp1070539rwl; Thu, 10 Aug 2023 06:08:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcP7yQQx7aWuqOy7AtXZVsJJYu4FHa7wkjCVTqk6iZmYMEMIlXBLAW8/cakHEMjPxphtY3 X-Received: by 2002:a05:6a00:2189:b0:676:76ea:e992 with SMTP id h9-20020a056a00218900b0067676eae992mr2721422pfi.5.1691672918793; Thu, 10 Aug 2023 06:08:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691672918; cv=none; d=google.com; s=arc-20160816; b=qvu1GRRvx5rMZfX9rZveAf4xKrWdMI8p/ug0CMiTLN3YP5T+3pmOV53KvhNd9wbe2X Qu/ygWLg9RYJmBPJqEK1o1CV+LFd54GSutqlgJ7sB/GxIGhiXS/fxkxOOOJGF6lW3K0v YQWYtc6kB/Ui4Jh5ddoOS9iTmh8Rh9ZnxEEZr6HXL19n/tCnucMs+4Fg+XS8k2rsus79 6dFgvUA52jT1XtwO8vOrHjQzlhAe04V7TJFknWr1wnmdJnQqDHY66vOEShTUe+wLOziT dV11E9xAxhG1bnBcUTmSlJZXO5Kd0XKoUQmd6VzgYmh6WMMkjPGcXkMKbYAU4dQNSygZ xAiw== 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 :message-id:date:subject:to:from; bh=o8n3Q5MbxN2vGmOP7Z1ZO7I+ZmvNJE+FQllvM6XGqCU=; fh=eZW+QzBGM/JDhNmJBpuL+C5WSyOH+cOd5OOFFgWy9F4=; b=M60zG0L50DkZOzKw6vDjATsToxE9zAtw2sn0EgKJNv6s0p+QF4bBLxcFXbyAYUUNMH 68l2GB5rqRT+yEv6X198S6L4TF8LkKP4OLOdDdsMAyF6f0KIsCKM038GnlMcl5EZHZTy XIQKjzqwLQ/RxutTIgNoLDTXxyyOC80bdqV3C4yf+3fbOLeSyirR3lTt95V998Xdwmm1 GH+OZ8gB1t4OjbB7m3kgkTb/Grs3jwkeP6EP3lmnlBajK85oM36Tr/2n35ZbkifJVn2A Ty+y6VOklITOlmsPkMSRMz7fTVMSA4oGj9x8MwGAwHbkGTcT0LXY5rJZ1BUEUUjrX+hw dq0w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t37-20020a056a0013a500b0066d45f035a5si1525428pfg.320.2023.08.10.06.08.25; Thu, 10 Aug 2023 06:08:38 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233824AbjHJMO1 (ORCPT + 99 others); Thu, 10 Aug 2023 08:14:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230147AbjHJMO0 (ORCPT ); Thu, 10 Aug 2023 08:14:26 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59DD619F for ; Thu, 10 Aug 2023 05:14:25 -0700 (PDT) Received: from kwepemi500008.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RM5RT0RTfz1L9H6; Thu, 10 Aug 2023 20:13:09 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 10 Aug 2023 20:14:21 +0800 From: Ruan Jinjie To: , , , , , , , , Subject: [PATCH -next] misc: eeprom/idt_89hpesx: Switch to memdup_user_nul() helper Date: Thu, 10 Aug 2023 20:13:54 +0800 Message-ID: <20230810121354.2110227-1-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500008.china.huawei.com (7.221.188.139) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 Use memdup_user_nul() helper instead of open-coding to simplify the code. Signed-off-by: Ruan Jinjie --- drivers/misc/eeprom/idt_89hpesx.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c index 740c06382b83..433a4bc6b1c5 100644 --- a/drivers/misc/eeprom/idt_89hpesx.c +++ b/drivers/misc/eeprom/idt_89hpesx.c @@ -913,15 +913,9 @@ static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf, return 0; /* Copy data from User-space */ - buf = kmalloc(count + 1, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - if (copy_from_user(buf, ubuf, count)) { - ret = -EFAULT; - goto free_buf; - } - buf[count] = 0; + buf = memdup_user_nul(ubuf, count); + if (IS_ERR(buf)) + return PTR_ERR(buf); /* Find position of colon in the buffer */ colon_ch = strnchr(buf, count, ':'); -- 2.34.1