From patchwork Mon Sep 17 11:11:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 1466591 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id EEAA6DF2D8 for ; Mon, 17 Sep 2012 11:15:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755789Ab2IQLPO (ORCPT ); Mon, 17 Sep 2012 07:15:14 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:41325 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755749Ab2IQLPO (ORCPT ); Mon, 17 Sep 2012 07:15:14 -0400 Received: by dady13 with SMTP id y13so823904dad.19 for ; Mon, 17 Sep 2012 04:15:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=fAGM9r9f056xmFmqkCgv7PtHxZwYtBqkcGWPxaUjBWU=; b=jo0Zty6FYNWQBStKJkDsS6yanVySEIU2ZiEjauKlLjNEYFa0YOAuXMxBxjkkd2UbSE px07DiP7VdgZbS2WLSJtiYo1tCJWH2UuEtMZUPaIlIGgJedjZb224W8captKUT5mc+cX XqlAcs2j8Hll0J+W4s+gnFiY8WbGHtNSIqf7mfl9Zzah7YkVPkYQcz70DTE8b8x05Fvn fvYlzIUiSIbmGULiW3SQYt7nbvmGmELI/Lp6R8czVXAN94e6WSkCxfIPvPzrZ8doDZ1F ods8FsyqUVwMc0MmtESEh4tHl699r8cV2mkWbQBVqgHjs45Q9LJiZWPeMay5kJxxKzqe u5TQ== Received: by 10.68.234.65 with SMTP id uc1mr22101134pbc.89.1347880513535; Mon, 17 Sep 2012 04:15:13 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id pi1sm6785687pbb.7.2012.09.17.04.15.10 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 04:15:12 -0700 (PDT) From: Sachin Kamat To: linux-input@vger.kernel.org Cc: jkosina@suse.cz, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH Resend] HID: Fix return values in hid-core.c Date: Mon, 17 Sep 2012 16:41:56 +0530 Message-Id: <1347880316-24604-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQmcE5sQW/jNMV1xBhgtCqVZ8ci1PJpuDUTJpcLFKT5bFs/5LLGwZeftzyoM/LJD8q5ndBKz Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Return -ENOMEM instead of -1 if memory allocation fails. Return -EINVAL instead of -1 for stack overflow and underflow errors. Signed-off-by: Sachin Kamat --- drivers/hid/hid-core.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 16d6454..80b0218 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -126,7 +126,7 @@ static int open_collection(struct hid_parser *parser, unsigned type) if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { hid_err(parser->device, "collection stack overflow\n"); - return -1; + return -EINVAL; } if (parser->device->maxcollection == parser->device->collection_size) { @@ -134,7 +134,7 @@ static int open_collection(struct hid_parser *parser, unsigned type) parser->device->collection_size * 2, GFP_KERNEL); if (collection == NULL) { hid_err(parser->device, "failed to reallocate collection array\n"); - return -1; + return -ENOMEM; } memcpy(collection, parser->device->collection, sizeof(struct hid_collection) * @@ -170,7 +170,7 @@ static int close_collection(struct hid_parser *parser) { if (!parser->collection_stack_ptr) { hid_err(parser->device, "collection stack underflow\n"); - return -1; + return -EINVAL; } parser->collection_stack_ptr--; return 0;