linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Capella <sebastian.capella-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Sebastian Capella
	<sebastian.capella-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Pavel Machek <pavel-+ZI9xUNit7I@public.gmane.org>
Cc: len.brown-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	rjw-+BtOjEMDT1ZEFMq0/Lb3/3WsBbEqB2P/@public.gmane.org,
	linaro-dev-cunTk1MwBs8s++Sfvej+rw@public.gmane.org,
	linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	@lists.linaro.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH RFC 1/2] PM / Hibernate: use name_to_dev_t to parse resume
Date: Tue, 17 Sep 2013 13:50:21 -0700	[thread overview]
Message-ID: <20130917205021.20736.5257@capellas-linux> (raw)
In-Reply-To: <20130830184230.28518.71814@capellas-linux>

Quoting Sebastian Capella (2013-08-30 11:42:30)
> Quoting Pavel Machek (2013-08-30 04:35:33)
> > On Mon 2013-08-26 10:40:50, Sebastian Capella wrote:
> > > Quoting Pavel Machek (2013-08-25 08:38:11)
> > > > Is the allocation actually neccessary? At the very least this should
> > > > test for NULL...
> > > 
> > > name_to_dev_t expects a non-const name, but the buffer passed in
> > > is const.  I also am removing the '\n' if found at the end of the
> > > string which would violate the const.
> > 
> > Fix name_to_dev_t, then. No need to do memory allocation just to work
> > around const.
> > 
> Hi Pavel,
> 
> The issue is really Removing the \n from the user space input.  The
> flow is:
> const input buf -> copy to work buffer, remove newline -> name_to_dev_t
> 
>   ssize_t resume_store(..., const char *buf, size_t n)
>   // copy buf, strip off trailing newline, pass to name_to_dev_t
>   dev_t name_to_dev_t(char *name)
> 
> The const in the restore_store buffer comes from the function type of the
> store member of the kobj_attribute.  I don't believe this should be changed.
> 
> Currently, name_to_dev_t will fail in some cases if a trailing \n is present.
> Is it more appropriate to handle stripping the newline in the store
> function rather than modifying name_to_dev_t to clean it up?
> 
> It seems logical for name_to_dev_t to take a const name parameter as
> there should be no reason to modify the name buffer passed to it.
> I'll be happy to make a patch to do this, but without hardening
> name_to_dev_t against trailing newlines, it would not be neccesary for
> this problem.
> 
> Thanks for your time and comments!
> 

Hi Pavel,

Do you have any more feedback regarding leaving the strndup?

Thanks!

Sebastian

  reply	other threads:[~2013-09-17 20:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-21 19:46 [PATCH RFC 0/2] PM / Hibernate: sysfs resume Sebastian Capella
2013-08-21 19:46 ` [PATCH RFC 1/2] PM / Hibernate: use name_to_dev_t to parse resume Sebastian Capella
2013-08-25 15:38   ` Pavel Machek
     [not found]     ` <20130825153811.GA4795-tWAi6jLit6GreWDznjuHag@public.gmane.org>
2013-08-26 17:10       ` Sebastian Capella
2013-08-26 17:40     ` Sebastian Capella
2013-08-30 11:35       ` Pavel Machek
2013-08-30 18:42         ` Sebastian Capella
2013-09-17 20:50           ` Sebastian Capella [this message]
2013-09-18 13:01             ` Pavel Machek
2013-08-21 19:46 ` [PATCH RFC 2/2] PM / Hibernate: add section for resume options Sebastian Capella
2013-09-05 11:56   ` Pavel Machek

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=20130917205021.20736.5257@capellas-linux \
    --to=sebastian.capella-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
    --cc=len.brown-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=linaro-dev-cunTk1MwBs8s++Sfvej+rw@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=pavel-+ZI9xUNit7I@public.gmane.org \
    --cc=rjw-+BtOjEMDT1ZEFMq0/Lb3/3WsBbEqB2P/@public.gmane.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;
as well as URLs for NNTP newsgroup(s).