mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Giedrius Statkevičius" <giedrius.statkevicius@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Giedrius Statkevičius" <giedrius.statkevicius@gmail.com>,
	lidza.louina@gmail.com, markh@compro.net,
	gregkh@linuxfoundation.org,
	driverdev-devel@linuxdriverproject.org,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	sudipm.mukherjee@gmail.com
Subject: Re: [PATCH v3] staging: dgnc: check if kzalloc fails in dgnc_tty_init()
Date: Tue, 7 Apr 2015 18:35:51 +0300 (EEST)	[thread overview]
Message-ID: <alpine.LNX.2.03.1504071828390.19037@localhost.localdomain> (raw)
In-Reply-To: <20150407144832.GK16501@mwanda>

On Tue, 7 Apr 2015, Dan Carpenter wrote:

> You will need to update the subject to reflect the new patch.
> 
> The original code did check for kzalloc() failure but it had lots of
> checks scattered around instead nicely at the point where the memory
> was allocated.
> 

There are a lot missing too. For example in dgnc_sysfs.c there are no checks on
any _show() methods if ->channels[i] is NULL or not. And in some other places.

> The old code and the new code are both buggy though and will crash in
> dgnc_tty_uninit().  dgnc_found_board() does "One Err" style error
> handling so it's obviously buggy like the underside of a rock.
> https://plus.google.com/106378716002406849458/posts/dnanfhQ4mHQ
> 
> It's becoming a difficult thing to fix this because every time we look
> there are more things which don't make sense.
> 
> I believe that if you do:
> 
> > +err_free_channels:
> > +	for (i = i - 1; i >= 0; --i) {
> > +		kfree(brd->channels[i]);
> 		brd->channels[i] = NULL;
> 	}
> > +	return -ENOMEM;
> >  }
> 
> And add some NULL checks in dgnc_tty_uninit() to see if ->channels[i] is
> NULL before doing:
> 
> 	dgnc_remove_tty_sysfs(brd->channels[i]->ch_tun.un_sysfs);
> 
> and
> 	dgnc_remove_tty_sysfs(brd->channels[i]->ch_pun.un_sysfs);
> 
> Then it will fix the bug.
> 

Missed this. Yep, I agree. 

> Do these in a separate patch.  I'm looking for ways we can make this
> patch minimal.  Deleting the comments and the NULL check in
> dgnc_tty_init() is essential for the patch because otherwise the cleanup
> doesn't make sense.

Well, the point of the patch is to put alloc and checks in one place to make the
code less error and bug prone and fix some of bugs where ->channels[i] isn't
checked. Ok, I'll send a v5 that's split into two patches.

> 
> regards,
> dan carpenter
> 
> 

Su pagarba / Regards,
Giedrius

  reply	other threads:[~2015-04-07 15:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 10:26 [PATCH] " Giedrius Statkevičius
2015-04-07 10:41 ` Sudip Mukherjee
2015-04-07 11:53   ` Giedrius Statkevičius
2015-04-07 12:40 ` [PATCH v2] " Giedrius Statkevičius
2015-04-07 13:01   ` Dan Carpenter
2015-04-07 13:25     ` Giedrius Statkevičius
2015-04-07 14:11   ` [PATCH v3] " Giedrius Statkevičius
2015-04-07 14:24     ` Sudip Mukherjee
2015-04-07 14:37       ` Giedrius Statkevičius
2015-04-07 14:54         ` Dan Carpenter
2015-04-07 14:48     ` Dan Carpenter
2015-04-07 15:35       ` Giedrius Statkevičius [this message]
2015-04-07 15:46         ` Dan Carpenter
2015-04-07 16:11     ` [PATCH v4 1/3] staging: dgnc: clean up allocation of ->channels[i] Giedrius Statkevičius
2015-04-09 23:42       ` [PATCH v5 " Giedrius Statkevičius
2015-04-09 23:42       ` [PATCH v5 2/3] staging: dgnc: don't forget to check if ->channels[i] is NULL in dgnc_tty_uninit() Giedrius Statkevičius
2015-04-09 23:42       ` [PATCH v5 3/3] staging: dgnc: remove redundant !ch checks Giedrius Statkevičius
2015-04-07 16:11     ` [PATCH v4 2/3] staging: dgnc: don't forget to check if ->channels[i] is NULL in dgnc_tty_uninit() Giedrius Statkevičius
2015-04-07 16:11     ` [PATCH v4 3/3] staging: dgnc: remove redundant !ch checks Giedrius Statkevičius
2015-04-10  0:37       ` Dan Carpenter

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=alpine.LNX.2.03.1504071828390.19037@localhost.localdomain \
    --to=giedrius.statkevicius@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lidza.louina@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markh@compro.net \
    --cc=sudipm.mukherjee@gmail.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®