From patchwork Fri Jun 2 13:52:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 101262 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp205144obc; Fri, 2 Jun 2017 06:55:42 -0700 (PDT) X-Received: by 10.84.169.36 with SMTP id g33mr67676plb.0.1496411742829; Fri, 02 Jun 2017 06:55:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496411742; cv=none; d=google.com; s=arc-20160816; b=kqx274xGWx9cE2qNFf31VrMC3YQPYd/o/qUHdlQJtu3ZyVMamGH4XnaO6UELZwXJTT 8Flkrkr3Us0N+uX/tBVnuK6b5NE2vJee19RxuIj83V+GFkRDcmZIK814F5UQzzIm6pBn u7B/KFVaxTQQi0TEe4Y7rkVRkwI2f6cSOfyehXok0OTkYIK2HSb/fzgfGfAphhRv+t8d r4cQbjs3JplPZp0fiU3IHR1EVuPDHw606TDyfTolknKihcka/P8T/TBhkIGmEjDBBBbj 86XGlWgHlepJB+6x7yWDYQoDk499O/YlpjkLDArUqCpzzZUhlpXkHtF3gz2gJRMguOMc lqzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=j1yqrCYELjELx7ZTjaA+uToVdfJldYzToUaelzbKHa8=; b=hN9d9ETmErOVbW71kV83Nsmc8V9H9VUAL59DqmhqdlWmf0GoGxOlLVmtEd+eS2lLP4 rODP/ZiPRN/3DGtc7XWatmRXspO+ZJY9iOD8Lg29HMuf6kYNuT9H1U/oCxRB3TusCWKF pJ+SkVbyazhrAWNRirbBQxcL44dDbuK8cCqlbSNNObEaYnEfcC399Xrs9aBOd4CQ5UP6 p3pfA5oLlCk5KVXFDVg1Mi3xEStqjcbyvQ56edrnrl+gspmjR19jgLbFyS2/swF0Ps32 RaXvM+R8R7+gLvYepZ3zAtqhcH6yJ1EgdaMg/0A727QI+bbWhVj6+wW+7iIa7GzHlCnh o/Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l17si3183385pgj.43.2017.06.02.06.55.42; Fri, 02 Jun 2017 06:55:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751622AbdFBNzS (ORCPT + 2 others); Fri, 2 Jun 2017 09:55:18 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:37155 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751597AbdFBNzO (ORCPT ); Fri, 2 Jun 2017 09:55:14 -0400 Received: by mail-wm0-f48.google.com with SMTP id d127so27568852wmf.0 for ; Fri, 02 Jun 2017 06:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mPhgzxjHAPxa9HA9SJDfDOor8UpO7bC102tKT0TV7m8=; b=WeHXDuuvqK1yS8dk05qVl1GtLp+z/e9s8gQM91ghMR4nwBaMfkYcyBQ+4o83M2LK6k zamhKXtpdYSVUn7EGW/H3T3zH27+FMQaHXhgvlhrbP2RrAgQQ421pZW5qhVqdEQV+M8Q 8HWFpkaTMjpycGlLTNxiSNWPiMo7hdSfL5o64= 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:in-reply-to :references; bh=mPhgzxjHAPxa9HA9SJDfDOor8UpO7bC102tKT0TV7m8=; b=gqqONFODlbUPpsE6A5gPs/H8v8BfOJYOzx/I5cwiAKnhQS9ppksg16NBNXZ5Z6yQ2C Wjj0ijEtOdhMJEH/9hXBlQqWKb3zwh5qAksTZcqJt8jBkmX9CaMZnJXFvcRTTaDt+mL2 6vxfP/Boi3KceH/i5fE99XZfCDNO0+lhD6IDlhlBQAySK/sZbV9z4U6B2sIhpVzSP/gU pD7/e3FAoCp1q+CNvM2FD50gXMYmFKPo7wCX1v5rG7Eqzh0+//SrSkQILoFaKq/KuneY 1LKr8BdYPQM5nLQsE+uyF9P/dxto3XQe/EXxhxe3fsfp4eXJ2oOj7tbC4K9vNtRBf8fz 0eeA== X-Gm-Message-State: AODbwcC2xtg/dexIbu33oU3WXlPc0+8Z+QgugXbo6o8hmwRquUX2ScH2 HERp4wvqgo2xYkwBPbRfSA== X-Received: by 10.80.136.229 with SMTP id d92mr6303563edd.119.1496411707838; Fri, 02 Jun 2017 06:55:07 -0700 (PDT) Received: from localhost.localdomain ([105.151.155.95]) by smtp.gmail.com with ESMTPSA id g48sm9756076edc.8.2017.06.02.06.55.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 06:55:07 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Geliang Tang , Ard Biesheuvel , linux-kernel@vger.kernel.org, Matt Fleming Subject: [PATCH 11/13] efi/efi_test: Use memdup_user() helper Date: Fri, 2 Jun 2017 13:52:05 +0000 Message-Id: <20170602135207.21708-12-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170602135207.21708-1-ard.biesheuvel@linaro.org> References: <20170602135207.21708-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Geliang Tang Use memdup_user() helper instead of open-coding to simplify the code. Signed-off-by: Geliang Tang Acked-by: Ivan Hu Cc: Ard Biesheuvel Signed-off-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/test/efi_test.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c index 8cd578f62059..08129b7b80ab 100644 --- a/drivers/firmware/efi/test/efi_test.c +++ b/drivers/firmware/efi/test/efi_test.c @@ -71,18 +71,13 @@ copy_ucs2_from_user_len(efi_char16_t **dst, efi_char16_t __user *src, if (!access_ok(VERIFY_READ, src, 1)) return -EFAULT; - buf = kmalloc(len, GFP_KERNEL); - if (!buf) { + buf = memdup_user(src, len); + if (IS_ERR(buf)) { *dst = NULL; - return -ENOMEM; + return PTR_ERR(buf); } *dst = buf; - if (copy_from_user(*dst, src, len)) { - kfree(buf); - return -EFAULT; - } - return 0; }