Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1732572imm; Thu, 14 Jun 2018 03:00:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKT88o/kmmFv00KbmM5hFzKOumy8j9s/31vDIksTzyaKAKI6qMp09zyJzp13Ik5kKHPKR5C X-Received: by 2002:a17:902:1029:: with SMTP id b38-v6mr2214461pla.277.1528970444706; Thu, 14 Jun 2018 03:00:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528970444; cv=none; d=google.com; s=arc-20160816; b=BXqOuX+tQ34sHpz1057zTcRpAJRM3o5aFaJH2wTSZL02D52FJ6ra4m7WnsASKv2ND3 0cOb9onNGPVIbqR5dNoPFX8PO+xbTJRQ5KwMRzBAFj1FszQ9nDJ8K4i4Tupp9NZPJqjF B6kxrjOtEc1d9zZCRiRRq/HpKe/bteSDaTGWSvEk0puBH2TfpZjvGBYkiYyB3bM/oVkf pwFxbFaX2kctez1/4+0OUWgP9Fuj1jMXv76X0b5JQRQF8e8dhjvswinyEdy0xw0xrq3A fGI0l4HjRt5/34LC2SrUjKhdYrIEav+9SM1wLPdKlYc4Lp2722ueHngtafrnR6KMIkcD pKhw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=tfoXcyNjpNeM1/EzAjzryQLrNkik/Pxcb7ZWbr9Hhk4=; b=rThdF7kzfGEr/il+AUge1c3BeuEuLLi3gdJopl12dHFVIDMlujdRz3TYP+FefZT9gX M1Dca//EdMAQNX6cadsfYgC6SEBq3X1ZGOj+OxCYvs4JN6rL7qouGqDI9jjyHN/kJLtI 4CLnxCVcCcUYefyCiUqMeKsp8nwg0LDrqpfFpJj0wKPrnZvZktABsKuaVxG0DfryXiru EbMrjETFJBksaeb9RadXI/JVQ6uf8Qggiz0v+u1NzLdEbdOybqpzQJhU0CO9DmLV5yc2 hYtspBbk2ZR2Fs6MbLOCvbWa+uO7XMZCG5gNwba3iQpxIWFKo+BfSYHqmf/aG7qnZsSP 2XSw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10-v6si4963111plh.306.2018.06.14.03.00.30; Thu, 14 Jun 2018 03:00: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754910AbeFNJ6p (ORCPT + 99 others); Thu, 14 Jun 2018 05:58:45 -0400 Received: from smtp65.iad3a.emailsrvr.com ([173.203.187.65]:48920 "EHLO smtp65.iad3a.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754633AbeFNJ6o (ORCPT ); Thu, 14 Jun 2018 05:58:44 -0400 Received: from smtp17.relay.iad3a.emailsrvr.com (localhost [127.0.0.1]) by smtp17.relay.iad3a.emailsrvr.com (SMTP Server) with ESMTP id 8B60A25FB1 for ; Thu, 14 Jun 2018 05:58:43 -0400 (EDT) Received: from smtp105.iad3b.emailsrvr.com (relay.iad3a.rsapps.net [172.27.255.110]) by smtp17.relay.iad3a.emailsrvr.com (SMTP Server) with ESMTPS id 8533125F14 for ; Thu, 14 Jun 2018 05:58:43 -0400 (EDT) Received: from smtp22.relay.iad3b.emailsrvr.com (localhost [127.0.0.1]) by smtp22.relay.iad3b.emailsrvr.com (SMTP Server) with ESMTP id D095F60075; Thu, 14 Jun 2018 05:58:42 -0400 (EDT) X-Auth-ID: siepeng@mev.co.uk Received: by smtp22.relay.iad3b.emailsrvr.com (Authenticated sender: siepeng-AT-mev.co.uk) with ESMTPSA id 37E886006D; Thu, 14 Jun 2018 05:58:42 -0400 (EDT) X-Sender-Id: siepeng@mev.co.uk Received: from [10.0.0.185] (remote.quintadena.com [81.133.34.160]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA) by 0.0.0.0:465 (trex/5.7.12); Thu, 14 Jun 2018 05:58:42 -0400 Subject: Re: [PATCH] staging: comedi: add error handling for vmap To: Zhouyang Jia , Dan Carpenter Cc: devel@driverdev.osuosl.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org References: <1528773937-38106-1-git-send-email-jiazhouyang09@gmail.com> <20180612115039.sz4zjgf7vrudpvyx@mwanda> From: Ian Abbott Organization: MEV Ltd. Message-ID: Date: Thu, 14 Jun 2018 10:58:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/06/18 08:57, Zhouyang Jia wrote: > Hi, > > I reported this bug since more than 90% callsites of vmap are > well handled in kernel. The caller function __comedi_buf_alloc > has no return value, so I don't know how the error is handled in > its caller. > > I believe there would be a better error handling method, but I > have limited domain knowledge, so I'm sorry I can't help here. > > Thanks for your kind reply. > > Best, > Zhouyang __comedi_buf_alloc is just a helper function factored out of, and called by comedi_buf_alloc. __comedi_buf_alloc does not clean up after itself on error because it expects comedi_buf_alloc to detect the error and call __comedi_buf_free to clean up any partially allocated mess: __comedi_buf_alloc(dev, s, n_pages); if (!async->prealloc_buf) { /* * [This is not the actual comment in the code!] * * Error occured in __comedi_buf_alloc(). * Buffer may be partially allocated. * Call __comedi_buf_free() to clean it up. */ __comedi_buf_free(dev, s); return -ENOMEM; } > > > > 2018-06-12 19:50 GMT+08:00 Dan Carpenter >: > > On Tue, Jun 12, 2018 at 11:25:35AM +0800, Zhouyang Jia wrote: > > When vmap fails, the lack of error-handling code may > > cause unexpected results. > > > > This patch adds error-handling code after calling vmap. > > > > Again, this is not error handling, this is just an error message.  This > error condition is handled in the caller. > > regards, > dan carpenter > > > -- -=( Ian Abbott || Web: www.mev.co.uk )=- -=( MEV Ltd. is a company registered in England & Wales. )=- -=( Registered number: 02862268. Registered address: )=- -=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-