[PATCH RFC 1/2] PM / Hibernate: use name_to_dev_t to parse resume
sebastian.capella at linaro.org
Fri Aug 30 14:42:30 EDT 2013
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.
The issue is really Removing the \n from the user space input. The
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
Thanks for your time and comments!
More information about the linux-arm-kernel