All of lore.kernel.org
 help / color / mirror / Atom feed
From: linux@audioscience.com
To: patch@alsa-project.org
Cc: Eliot Blennerhassett <eblennerhassett@audioscience.com>,
	alsa-devel@alsa-project.org
Subject: [PATCH - asihpi 3/4] Subsystem message now outside adapter#0 mutex. Fixes segfault when no adapter#0 present.
Date: Wed, 09 Jul 2008 11:10:40 +1200	[thread overview]
Message-ID: <1215558641-19514-3-git-send-email-linux@audioscience.com> (raw)
In-Reply-To: <1215558641-19514-2-git-send-email-linux@audioscience.com>

From: Eliot Blennerhassett <eblennerhassett@audioscience.com>


Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com>

diff --git a/pci/asihpi/hpioctl.c b/pci/asihpi/hpioctl.c
index 5192db3..a13748d 100644
--- a/pci/asihpi/hpioctl.c
+++ b/pci/asihpi/hpioctl.c
@@ -106,20 +106,11 @@ int asihpi_hpi_release(
 	return 0;
 }
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 11)
 long asihpi_hpi_ioctl(
 	struct file *file,
 	unsigned int cmd,
 	unsigned long arg
 )
-#else
-int asihpi_hpi_ioctl(
-	struct inode *inode,
-	struct file *file,
-	unsigned int cmd,
-	unsigned long arg
-)
-#endif
 {
 	struct hpi_ioctl_linux __user *phpi_ioctl_data;
 	void __user *phm;
@@ -127,7 +118,7 @@ int asihpi_hpi_ioctl(
 	struct hpi_message hm;
 	struct hpi_response hr;
 	u32 uncopied_bytes;
-	struct hpi_adapter *pa;
+	struct hpi_adapter *pa = NULL;
 
 	if (cmd != HPI_IOCTL_LINUX)
 		return -EINVAL;
@@ -145,27 +136,29 @@ int asihpi_hpi_ioctl(
 		return -EFAULT;
 
 	pa = &adapters[hm.wAdapterIndex];
-
-	if ((hm.wAdapterIndex > HPI_MAX_ADAPTERS) || (!pa->type)) {
-		HPI_InitResponse(&hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_OPEN,
-			HPI_ERROR_BAD_ADAPTER_NUMBER);
-
-		uncopied_bytes = copy_to_user(phr, &hr, sizeof(hr));
-		if (uncopied_bytes)
-			return -EFAULT;
-		return 0;
-	}
-
 	hr.wSize = 0;
-	/* Response filled either copy from cache, or by HPI_Message() */
-	{
-		/* Dig out any pointers embedded in the message.  */
+	if (hm.wObject == HPI_OBJ_SUBSYSTEM) {
+		HPI_MessageF(&hm, &hr, file);
+	} else {
 		u16 __user *ptr = NULL;
 		u32 size = 0;
 
 		/* -1=no data 0=read from user mem, 1=write to user mem */
 		int wrflag = -1;
 		u32 nAdapter = hm.wAdapterIndex;
+
+		if ((hm.wAdapterIndex > HPI_MAX_ADAPTERS) || (!pa->type)) {
+			HPI_InitResponse(&hr, HPI_OBJ_ADAPTER,
+				HPI_ADAPTER_OPEN,
+				HPI_ERROR_BAD_ADAPTER_NUMBER);
+
+			uncopied_bytes = copy_to_user(phr, &hr, sizeof(hr));
+			if (uncopied_bytes)
+				return -EFAULT;
+			return 0;
+		}
+
+		/* Dig out any pointers embedded in the message.  */
 		switch (hm.wFunction) {
 		case HPI_SUBSYS_CREATE_ADAPTER:
 		case HPI_SUBSYS_DELETE_ADAPTER:
-- 
1.5.4.3

  reply	other threads:[~2008-07-08 23:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-08 23:10 [PATCH - asihpi 1/4] V3.10.1. Add hpi_RDS enum linux
2008-07-08 23:10 ` [PATCH - asihpi 2/4] Regularise control creation. Add readonly AESEBU status control. Fix ChannelMode enumeration linux
2008-07-08 23:10   ` linux [this message]
2008-07-08 23:10     ` [PATCH - asihpi 4/4] HPI v3.10.03. Formatting tweaks linux
2008-07-08 23:43 ` [PATCH - asihpi 1/4] related firmware Eliot Blennerhassett
2008-07-10 16:14 ` [PATCH - asihpi 1/4] V3.10.1. Add hpi_RDS enum Takashi Iwai

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=1215558641-19514-3-git-send-email-linux@audioscience.com \
    --to=linux@audioscience.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=eblennerhassett@audioscience.com \
    --cc=patch@alsa-project.org \
    /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.