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: 11460 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0BD1F23E29 for ; Mon, 17 Sep 2012 11:15:16 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 55E4BA1BF2E for ; Mon, 17 Sep 2012 11:15:15 +0000 (UTC) Received: by ieak11 with SMTP id k11so9029613iea.11 for ; Mon, 17 Sep 2012 04:15:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=fAGM9r9f056xmFmqkCgv7PtHxZwYtBqkcGWPxaUjBWU=; b=UpnRLPCwtRQS877cRNi59aiBZSJ5e5jqVDhAlMna3MFkAaYRyq4mL2BTkaF+Rf4yYb Ss/zBJZjf4HIGZckQ4VXaBwGkUeVqvds7HR66BX/PETjg91DLViUA3CyjuWgsjfr9JIm m2Jz+etjIGSAq87RDtWoFcbH/lbmyO5nW3QptaKMK8JPNkdIZCKUnCzajhXw+LFqzyF8 MZzpm0Ds6Vohew9tfe407wDyNwlkfNbzKGq0btWUoKxoY3e9nfOxNSqcPl91jOR87lm9 cXADtj9R52qbwOeni6JSXjD/DKXVKy0C8qMKrfw4qfSHPoos5Qp4NNUKeuC+5YX5nx7F eZmQ== Received: by 10.50.0.193 with SMTP id 1mr4291227igg.0.1347880514720; Mon, 17 Sep 2012 04:15:14 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp308610igc; Mon, 17 Sep 2012 04:15:14 -0700 (PDT) Received: by 10.68.229.138 with SMTP id sq10mr22383149pbc.126.1347880513960; Mon, 17 Sep 2012 04:15:13 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id px6si15225098pbc.64.2012.09.17.04.15.13 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 04:15:13 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by pbcmd12 with SMTP id md12so10153515pbc.37 for ; Mon, 17 Sep 2012 04:15:13 -0700 (PDT) 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: ALoCoQn98Xttofr3l8bcqwi7NwELRfE+eD83oKu+lCMC23EwQkhW0o2nD1ppUh/aoQykuPQov11N 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;