Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4823389imm; Mon, 11 Jun 2018 20:27:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLmhh9XSK0sLWWKALmd6PNnOUC5dHKiC7mLzMR5uKcv7i6/IPEcWM/IhZpicspt1hRvSk8m X-Received: by 2002:a62:d2c3:: with SMTP id c186-v6mr1930515pfg.44.1528774064912; Mon, 11 Jun 2018 20:27:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528774064; cv=none; d=google.com; s=arc-20160816; b=dRe/2IAEdowQLse9svXyw1gmhShtpm3mJ0Mk0B7pTPnU2r5AS2+oTO2HIjC+GNzzgg 5jmtWzgmFZSSlzol8uhhktmkFbDmvIBZGllQIF0j26b/HxuP4k++kjC0zxT2v3UNSA6J Gs5KAheQMfIytBaJmwCDo8IHUi3bBFQSi2P0vbJMvD2R/eZXsaOxBzZ9jZf8F48sIQN2 cLIp8b/HhY2aFvOAqvH9NGJhazYu6Idp3HTjUJ/rPypSbyhxUYOn9unlzCzU2AnTy+Hk e4b+e4mBjThVuIsV52jIQftxqoivjPcyXQvY1/C1ROdodWKlt55qw+asABbmckR8+AEH SL2g== 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=117ZWbFI1Na+M2u1QTj6v+FqnE4w0SNp8iGHTy7Pcqo=; b=Z+xp7l5MMh3HgMp+KvtBitDpykJwEDq3SY5DkOBz5k/HRyETps585uwDWeHzU/O3xn PJq3+1ZpvyPDs7B3cG69GjcOrdux8TmNn0AZo0N42TsSzUlO4DbsV9c3SHDGNwJ6LOj4 KIN/PrqdhuD7Z9Euveeo9nn3f+LpIvWNb9IfszVORkTxoL1/6jM89SHIdFZAnCXhHX37 XDlVWo650hXjSgaZoELEVWDsg9lx0d9Uh/+ok9Trb/fvQhB4/HN4TXuz7rAjemEuooLi Vvj8CYguUPsUYchPzGvSq8as1/5ozUE0/WTU+6H4aFBt9KSuP9wIhoLFOhL4fkgL6xX9 gAIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Ga+g06lV; 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 t13-v6si1466970pgs.661.2018.06.11.20.27.30; Mon, 11 Jun 2018 20:27:44 -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=Ga+g06lV; 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 S932831AbeFLD0H (ORCPT + 99 others); Mon, 11 Jun 2018 23:26:07 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36645 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932650AbeFLD0G (ORCPT ); Mon, 11 Jun 2018 23:26:06 -0400 Received: by mail-pf0-f195.google.com with SMTP id a12-v6so11333581pfi.3 for ; Mon, 11 Jun 2018 20:26:06 -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=117ZWbFI1Na+M2u1QTj6v+FqnE4w0SNp8iGHTy7Pcqo=; b=Ga+g06lVeT6s1gEDqOHaotB1PnF8uyAtsIF9ilqCJBgMYioGIVuMo/f6nzZxMCthft ItZS6+fYbvG4He28N+9ZACThi5R7HH42RHZfMB9hjljk5ByX3c4Os5fNyJDbqoOn0cHV RwM8m+u6QCaullHK9UCzGM/HZPUVWzGQm27Pe3FQK1NNp+cM8cb9A5hSz2+zcTSFZ3Ah sgcdC5j2Pf6QUvyGsbVWiZEleUOZeFfSc53aU5BscTz5DqGbEn4rQVe0O//uQVOtZv/0 ON8idnEhw2+K37VO3TKDduJFenpx/RAjmg/4Si8tjUZ4CESV8ReiKiC7bQBw87Cj2/BK gNFw== 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=117ZWbFI1Na+M2u1QTj6v+FqnE4w0SNp8iGHTy7Pcqo=; b=Ee8L5OFBZojyxjML0g3HQ3lMWy/qr2TZZaZUvcchUqUhbJu83fJgfte/Vdn11Bq98h pI+0idec4dKx6PzF2GgKn/DJ+eHnLB1Z+0L9hqYMooZzBh/ryWbWe94DcoP470M5QhUQ Gck0SZ+4nqsTdpM/djb0si0JOwBcFAzDkHH02UJVPbT0HqKc1r5qtFCOTADrDjJ/XqIh 6nTXH7RM3+raXssQ3FZXXmTZXvoNnTlVwOcP7nfydg9FvFRVxB6Vzd4Qu2Ye1auVDPRw 5eoRP5fqJaaT0nET8Fmm8XlwXHzIlQDbre/BanKjjbcIHB2fIKyJggWaA0y5w8sFLRU0 czJA== X-Gm-Message-State: APt69E0iJV6uFjHTwpoR30iSzIspsRbRBUJebNsBjOu4TCAYT3I/YWXy 6U9raGKOEhP5lxHJZ/cjXDg= X-Received: by 2002:a62:3a59:: with SMTP id h86-v6mr1888815pfa.209.1528773965916; Mon, 11 Jun 2018 20:26:05 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id e16-v6sm32587997pff.185.2018.06.11.20.26.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 20:26:05 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Ian Abbott , H Hartley Sweeten , Greg Kroah-Hartman , Amitoj Kaur Chawla , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: comedi: add error handling for vmap Date: Tue, 12 Jun 2018 11:25:35 +0800 Message-Id: <1528773937-38106-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 vmap fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling vmap. Signed-off-by: Zhouyang Jia --- drivers/staging/comedi/comedi_buf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index f693c2c..5e48693 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -132,9 +132,12 @@ static void __comedi_buf_alloc(struct comedi_device *dev, spin_unlock_irqrestore(&s->spin_lock, flags); /* vmap the prealloc_buf if all the pages were allocated */ - if (i == n_pages) + if (i == n_pages) { async->prealloc_buf = vmap(pages, n_pages, VM_MAP, COMEDI_PAGE_PROTECTION); + if (!async->prealloc_buf) + dev_err(dev->class_dev, "failed to vmap pages\n"); + } vfree(pages); } -- 2.7.4