Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4869912imm; Mon, 11 Jun 2018 21:34:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL9S9BtwgEvz5ShG8IWEo+nb+AS2AW1M9WCP+DZdIaGcukZAJHOI8cOYrzxzT+kdD0rCsK4 X-Received: by 2002:a17:902:5602:: with SMTP id h2-v6mr2252192pli.314.1528778093913; Mon, 11 Jun 2018 21:34:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528778093; cv=none; d=google.com; s=arc-20160816; b=khMKORcG3G/wY4F5dPgGbmxa6I5/lfHGw3jdsCYqQnyaYhvMhVp23ghjSHypehcOe6 llW8fuE0N2Qj7o/Eki0U6Kjz682cMuhNvApuixgA0THgjl+AynZKCppwZ3v3aC/WL6EL FCRQKPmBlLXWh363uyz2EeV1JKKmR3PgdMd1krPRRMNKwBXAZSmFNJ2qFYILTVwRhttl DwLrqRf+vuRRTYIHbGcfKC6YqfIQIOPNNg1125gltnbl4R0rzwwenXuR3ByyKS9LtfXR N+nH/o0MkqaeCBQeYmnQby1vpiGe0QBA81zl16WQUfow59AjPxcEwnb2uv1uYPHUxgim gNPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature:arc-authentication-results; bh=gYSp71olMKMamF+jwuSrnKTDB+rrLt2g7gviGYiZIrg=; b=NMcCE68hz/hmmHyCQUa+Bs7c+mVXrg+fGxEiehy3IP8J+jPvVsHNSy0X/xfP5zjOd6 K64dFQ+mQTapuQpV6MdLeMbVOOnjZlJG8ewFbEEdsiCr5VT8/ot2dmm9Ity8sQEwN2Df qg7IB/PaIMiOXs/H3RrAhHacowBNI3hiiEVmj1SSNHSFlGEPz2FaR94nB0h5ggInfRQm Wv0sVu7ktVVoWm7Z4ilHpCZdS1BT+sThTi6ofIhbgGknRk0Jp9BENlEiGTn+8JJBCc/S cLQIKbe7gvVKCO9H4nTt3OPmNBl+jLH6/69v2dLRAft7PR1Hc2g/zoMJEU280fYFS8iX EMdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=fw0UWdG+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l65-v6si31506563pge.46.2018.06.11.21.34.39; Mon, 11 Jun 2018 21:34:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=fw0UWdG+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754011AbeFLEeU (ORCPT + 99 others); Tue, 12 Jun 2018 00:34:20 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:46973 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752816AbeFLEeT (ORCPT ); Tue, 12 Jun 2018 00:34:19 -0400 Received: by mail-pf0-f196.google.com with SMTP id q1-v6so11399215pff.13 for ; Mon, 11 Jun 2018 21:34:18 -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; bh=gYSp71olMKMamF+jwuSrnKTDB+rrLt2g7gviGYiZIrg=; b=fw0UWdG+OXJM6p0wutRNBvMuUTYUnakGKVNbC0tXZnnQty/Z15zeD7AHQ1OWzJqpGl ZhKuuO6NNflyXurLZ5phMikqrvjBVSSx0R3O1FfCEFYYKV0FrBuftuCNB9lz3atYjyFp RkFkKpmXPlLOvowreMTtoH5gcFoQkE888qeixKl4VA1Q8nn/TFhSF3sN4UtRhPqQ2IEu YQeeB19kDc8usT/TZ/8uEMOfBvjFqQtU4W9qkVx8M34VPXFTn95l3qQkvZJB/CEcb92f YfPiUMWuWdwnRxwzpLVBw9x1Fxsxx/Z2lyjydRU8KCrVAfwvU2vyet2FmWIn1A5dohdD WW0g== 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; bh=gYSp71olMKMamF+jwuSrnKTDB+rrLt2g7gviGYiZIrg=; b=CELRE2upzSl3qPcOhoXn0CAfB2ASEBAMUu21TjzOy984/iqA0WSsHZrp8U/3k7y237 XhQp6GqlRlK8y4ONmqp39JPJ6eTvOz/a/jlkhEbJXfUz88jyq40Ymd/7CeMPSL2kqVbZ wW7T/Pp27gcnmFLewljhmMYSTaf1ncFDUuoOnYC6t/Sc9XlyJEcayyEUffGmGhKq+z0L tLIH+0UgvTOTNOpVAuN/3WfBk0Bup9NmlFjBoqWv0w1b37KwzJCBL9kpM8MX+zZMO0tv cHjpibeBe2WO1pWpqjKjZnPDFqdDi2zAiq8zj3SorUoQNsWTeMtInMf7ldTFcpKyWnoA TZKg== X-Gm-Message-State: APt69E2CztH2QphEAoKE31t9v2hn5dAPJ7a6gPGBo/n2Ey94aHa8JAPv 3d1R9k8fUZnj3KYVlxvdmmYdNeftchA= X-Received: by 2002:aa7:8298:: with SMTP id s24-v6mr2127343pfm.136.1528778058630; Mon, 11 Jun 2018 21:34:18 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id u14-v6sm14079259pfd.103.2018.06.11.21.34.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 21:34:17 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Jan Harkes , coda@cs.cmu.edu, codalist@coda.cs.cmu.edu, linux-kernel@vger.kernel.org Subject: [PATCH] fs/coda: add error handling for fget Date: Tue, 12 Jun 2018 12:34:12 +0800 Message-Id: <1528778052-41025-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When fget fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling fget. Signed-off-by: Zhouyang Jia --- fs/coda/psdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index c5234c2..55824cb 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c @@ -187,8 +187,11 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, if (req->uc_opcode == CODA_OPEN_BY_FD) { struct coda_open_by_fd_out *outp = (struct coda_open_by_fd_out *)req->uc_data; - if (!outp->oh.result) + if (!outp->oh.result) { outp->fh = fget(outp->fd); + if (!outp->fh) + return -EBADF; + } } wake_up(&req->uc_sleep); -- 2.7.4