From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751153AbbJCVer (ORCPT ); Sat, 3 Oct 2015 17:34:47 -0400 Received: from lists.s-osg.org ([54.187.51.154]:47225 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750883AbbJCVep (ORCPT ); Sat, 3 Oct 2015 17:34:45 -0400 Message-ID: <561049F1.5040507@osg.samsung.com> Date: Sat, 03 Oct 2015 22:34:41 +0100 From: Luis de Bethencourt User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: Jiri Kosina CC: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-input@vger.kernel.org Subject: Re: [PATCH] HID: hiddev: fix returned errno code in hiddev_connect() References: <1443606749-6028-1-git-send-email-luisbg@osg.samsung.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30/09/15 20:40, Jiri Kosina wrote: > On Wed, 30 Sep 2015, Luis de Bethencourt wrote: > >> The driver is using -1 instead of the -ENOMEM defined macro to specify >> that a buffer allocation failed. Since the error number is propagated, >> the caller will get a -EPERM which is the wrong error condition. > > Generally I agree that the more specific errno, the better. > > But I am not really sure where you are seeing the bug (mapping to -EPERM) > in this case? I think the only caller of hiddev_connect() should be > hid_connect(), and the only thing that guy cares about whether individual > callbacks succeed or fail, so that it sets hdev->clamed flags accordingly. > > Could you please be more specific about the -EPERM mapping you are talking > about? > > Thanks, > I agree with you. The only caller of hiddev_connect() only checks if the callback succeded. It checks if the return < 0. What I meant is that -1 means -EPERM. [0] This patch is purely about the correctness of using -ENOMEM. The word "propagated" was not the best way to describe this problem. I could edit the commit message if you would like. Thanks for the review, Luis [0] http://lxr.free-electrons.com/source/include/uapi/asm-generic/errno-base.h#L15