From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Russ Gorby <russ.gorby@intel.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
linux-kernel@vger.kernel.org, suhail.ahmed@intel.com
Subject: Re: [PATCH 1/5] tty: n_gsm: Add raw-ip support
Date: Mon, 6 Jun 2011 10:28:54 +0100 [thread overview]
Message-ID: <20110606102854.2f689349@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <1307127821-21665-2-git-send-email-russ.gorby@intel.com>
> @@ -1590,6 +1616,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
> dlci->addr = addr;
> dlci->adaption = gsm->adaption;
> dlci->state = DLCI_CLOSED;
> + dlci->net = NULL; /* network not initially created */
kzalloc ised used anyway so this starts NULL
>
> +int gsm_change_mtu(struct net_device *net, int new_mtu)
> +{
> + if ((new_mtu < 8) || (new_mtu > MAX_MTU))
> + return -EINVAL;
> + net->mtu = new_mtu;
> + return 0;
> +}
Surely at that point you need to renegotiate the DLCI parameters for the
DLCI in question. At the very least you need to sanity check versus the
current settings ?
> +static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc)
> +{
> + char *netname;
> + int retval = 0;
> + struct net_device *net;
> + struct gsm_mux_net *mux_net;
> +
> + if (!capable(CAP_NET_ADMIN))
> + return -EPERM;
> +
> + /* Already in a non tty mode */
> + if (dlci->adaption > 2)
> + return -EBUSY;
Only you don't have any locking so two ioctls at once will get very
confused
> + if (retval) {
> + pr_err("network register fail %d\n", retval);
> + free_netdev(net);
> + goto error_ret;
And this leaves the DLCI messed up
> + kref_init(&mux_net->ref);
What stops this getting referenced between the net register and here ?
On the destroy side you don't seem to put back the old adaption settings
and restore the state (and also have locking v another ioctl missing)
Doesn't look too hard to fix - save the old dlci states when you go
network, put them back when you destroy the network state. For the ioctls
you probably need to cover most of each one with the mutex.
next prev parent reply other threads:[~2011-06-06 9:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <[PATCH 0/5] N_GSM patchset : 06/03/2011>
2011-06-03 19:03 ` [PATCH 0/5] N_GSM patchset : 06/03/2011 Russ Gorby
2011-06-03 19:03 ` [PATCH 1/5] tty: n_gsm: Add raw-ip support Russ Gorby
2011-06-06 9:28 ` Alan Cox [this message]
2011-06-06 19:50 ` Gorby, Russ
2011-06-03 19:03 ` [PATCH 2/5] tty: n_gsm: expose gsmtty device nodes at ldisc open time Russ Gorby
2011-06-03 22:02 ` Alan Cox
2011-06-03 19:03 ` [PATCH 3/5] tty: n_gsm: Added refcount usage to gsm_mux and gsm_dlci structs Russ Gorby
2011-06-03 22:08 ` Alan Cox
2011-06-03 19:03 ` [PATCH 4/5] tty: n_gsm: initiate close of all DLCIs during mux shutdown Russ Gorby
2011-06-03 22:05 ` Alan Cox
2011-06-06 17:09 ` Gorby, Russ
2011-06-03 19:03 ` [PATCH 5/5] tty: n_gsm: Fixed NULL ptr OOPs in tty_write_room() Russ Gorby
2011-06-03 22:10 ` Alan Cox
2011-06-06 17:13 ` Gorby, Russ
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=20110606102854.2f689349@lxorguk.ukuu.org.uk \
--to=alan@lxorguk.ukuu.org.uk \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=russ.gorby@intel.com \
--cc=suhail.ahmed@intel.com \
/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
all inboxes | Powered by JetHome®