All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Praznik <frank.praznik@oh.rr.com>
To: linux-input@vger.kernel.org
Cc: jkosina@suse.cz, pavel@ucw.cz, Frank Praznik <frank.praznik@oh.rr.com>
Subject: [PATCH v2 1/6] hid: sony: Prevent the freeing of an unitialized ida value
Date: Tue,  5 May 2015 20:47:28 -0400	[thread overview]
Message-ID: <1430873253-11765-2-git-send-email-frank.praznik@oh.rr.com> (raw)
In-Reply-To: <1430873253-11765-1-git-send-email-frank.praznik@oh.rr.com>

sony_allocate_output_report() was being called before sony_set_device_id()
which meant that an unallocated ida value was was freed if the output
report allocation failed and the probe function jumped to err_stop.

Do the device ID allocation before the output report allocation to avoid
freeing an unallocated value in case of a failure.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
---
 drivers/hid/hid-sony.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 6ca96ce..4c521b2 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -1993,15 +1993,15 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		return ret;
 	}
 
-	ret = sony_allocate_output_report(sc);
+	ret = sony_set_device_id(sc);
 	if (ret < 0) {
-		hid_err(hdev, "failed to allocate the output report buffer\n");
+		hid_err(hdev, "failed to allocate the device id\n");
 		goto err_stop;
 	}
 
-	ret = sony_set_device_id(sc);
+	ret = sony_allocate_output_report(sc);
 	if (ret < 0) {
-		hid_err(hdev, "failed to allocate the device id\n");
+		hid_err(hdev, "failed to allocate the output report buffer\n");
 		goto err_stop;
 	}
 
-- 
2.1.0


  reply	other threads:[~2015-05-06  0:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-06  0:47 [PATCH v2 0/5] Support for the Sony Motion Controller and other cleanups Frank Praznik
2015-05-06  0:47 ` Frank Praznik [this message]
2015-05-06  9:24   ` [PATCH v2 1/6] hid: sony: Prevent the freeing of an unitialized ida value Pavel Machek
2015-05-06  0:47 ` [PATCH v2 2/6] hid: sony: Add the product ID for the Sony Motion Controller Frank Praznik
2015-05-06  0:47 ` [PATCH v2 3/6] hid: sony: Add support " Frank Praznik
2015-05-06  0:47 ` [PATCH v2 4/6] hid: sony: Correct Sony device ordering Frank Praznik
2015-05-06  0:47 ` [PATCH v2 5/6] hid: sony: Simplify LED initialization and eliminate redundant copies when updating LED states Frank Praznik
2015-05-06  0:47 ` [PATCH v2 6/6] hid: sony: Correct a typo in a HID descriptor comment and explain the odd Sixaxis axis mapping Frank Praznik
2015-05-07  8:43 ` [PATCH v2 0/5] Support for the Sony Motion Controller and other cleanups Jiri Kosina
2015-05-27 15:46 ` simon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1430873253-11765-2-git-send-email-frank.praznik@oh.rr.com \
    --to=frank.praznik@oh.rr.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.