public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Hunold <hunold@convergence.de>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH][2.6] DVB:Fix adapter module removal bug
Date: Thu, 29 Apr 2004 10:53:21 +0200	[thread overview]
Message-ID: <4090C281.5070604@convergence.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 208 bytes --]

Hello,

unfortunately it's possible to remove a DVB adapter module even if a DVB 
network device has been set up using this adapter.

The attached patch fixes this problem. Please apply. Thanks!

CU
Michael.

[-- Attachment #2: dvb_net.diff --]
[-- Type: text/plain, Size: 1261 bytes --]

diff -ur xx-linux-2.6.6-rc3/drivers/media/dvb/dvb-core/dvb_net.c linux-2.6.6-rc3/drivers/media/dvb/dvb-core/dvb_net.c
--- xx-linux-2.6.6-rc3/drivers/media/dvb/dvb-core/dvb_net.c	2004-04-29 10:38:36.000000000 +0200
+++ linux-2.6.6-rc3/drivers/media/dvb/dvb-core/dvb_net.c	2004-04-29 10:45:46.000000000 +0200
@@ -1095,9 +1095,15 @@
 		
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
+			
+		if (!try_module_get(dvbdev->adapter->module))
+			return -EPERM;
+
 		result=dvb_net_add_if(dvbnet, dvbnetif->pid, dvbnetif->feedtype);
-		if (result<0)
+		if (result<0) {
+			module_put(dvbdev->adapter->module);
 			return result;
+		}
 		dvbnetif->if_num=result;
 		break;
 	}
@@ -1120,6 +1126,7 @@
 	case NET_REMOVE_IF:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
+		module_put(dvbdev->adapter->module);
 		return dvb_net_remove_if(dvbnet, (int) (long) parg);
 
 	/* binary compatiblity cruft */
@@ -1130,9 +1137,15 @@
 
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
+
+		if (!try_module_get(dvbdev->adapter->module))
+			return -EPERM;
+
 		result=dvb_net_add_if(dvbnet, dvbnetif->pid, DVB_NET_FEEDTYPE_MPE);
-		if (result<0)
+		if (result<0) {
+			module_put(dvbdev->adapter->module);
 			return result;
+		}
 		dvbnetif->if_num=result;
 		break;
 	}

                 reply	other threads:[~2004-04-29  8:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4090C281.5070604@convergence.de \
    --to=hunold@convergence.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox