* [PATCH v2] apparmor/file: Removing unnecessary initial values for variable pointers
@ 2023-09-19 1:56 Li kunyu
2023-09-28 17:36 ` John Johansen
0 siblings, 1 reply; 3+ messages in thread
From: Li kunyu @ 2023-09-19 1:56 UTC (permalink / raw)
To: john.johansen, paul, jmorris, serge
Cc: apparmor, linux-security-module, linux-kernel, Li kunyu
These variable pointers are assigned during use and do not need to be
initialized for assignment.
Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
v2: Fix timestamp issues
security/apparmor/file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/apparmor/file.c b/security/apparmor/file.c
index 698b124e649f..12eafdf18fc0 100644
--- a/security/apparmor/file.c
+++ b/security/apparmor/file.c
@@ -264,7 +264,7 @@ int aa_path_perm(const char *op, struct aa_label *label,
{
struct aa_perms perms = {};
struct aa_profile *profile;
- char *buffer = NULL;
+ char *buffer;
int error;
flags |= PATH_DELEGATE_DELETED | (S_ISDIR(cond->mode) ? PATH_IS_DIR :
@@ -412,7 +412,7 @@ int aa_path_link(struct aa_label *label, struct dentry *old_dentry,
d_backing_inode(old_dentry)->i_uid,
d_backing_inode(old_dentry)->i_mode
};
- char *buffer = NULL, *buffer2 = NULL;
+ char *buffer, *buffer2;
struct aa_profile *profile;
int error;
--
2.18.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] apparmor/file: Removing unnecessary initial values for variable pointers
2023-09-19 1:56 [PATCH v2] apparmor/file: Removing unnecessary initial values for variable pointers Li kunyu
@ 2023-09-28 17:36 ` John Johansen
2023-09-28 19:35 ` Serge E. Hallyn
0 siblings, 1 reply; 3+ messages in thread
From: John Johansen @ 2023-09-28 17:36 UTC (permalink / raw)
To: Li kunyu, paul, jmorris, serge
Cc: apparmor, linux-security-module, linux-kernel
On 9/18/23 18:56, Li kunyu wrote:
> These variable pointers are assigned during use and do not need to be
> initialized for assignment.
>
> Signed-off-by: Li kunyu <kunyu@nfschina.com>
> ---
> v2: Fix timestamp issues
>
> security/apparmor/file.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/security/apparmor/file.c b/security/apparmor/file.c
> index 698b124e649f..12eafdf18fc0 100644
> --- a/security/apparmor/file.c
> +++ b/security/apparmor/file.c
> @@ -264,7 +264,7 @@ int aa_path_perm(const char *op, struct aa_label *label,
> {
> struct aa_perms perms = {};
> struct aa_profile *profile;
> - char *buffer = NULL;
> + char *buffer;
this is okay
> int error;
>
> flags |= PATH_DELEGATE_DELETED | (S_ISDIR(cond->mode) ? PATH_IS_DIR :
> @@ -412,7 +412,7 @@ int aa_path_link(struct aa_label *label, struct dentry *old_dentry,
> d_backing_inode(old_dentry)->i_uid,
> d_backing_inode(old_dentry)->i_mode
> };
> - char *buffer = NULL, *buffer2 = NULL;
> + char *buffer, *buffer2;
this can cause an oops if buffer2 allocation fails. There are a couple of ways I can
see to fix this, do you want to take a crack at it.
> struct aa_profile *profile;
> int error;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] apparmor/file: Removing unnecessary initial values for variable pointers
2023-09-28 17:36 ` John Johansen
@ 2023-09-28 19:35 ` Serge E. Hallyn
0 siblings, 0 replies; 3+ messages in thread
From: Serge E. Hallyn @ 2023-09-28 19:35 UTC (permalink / raw)
To: John Johansen
Cc: Li kunyu, paul, jmorris, serge, apparmor, linux-security-module,
linux-kernel
On Thu, Sep 28, 2023 at 10:36:16AM -0700, John Johansen wrote:
> On 9/18/23 18:56, Li kunyu wrote:
> > These variable pointers are assigned during use and do not need to be
> > initialized for assignment.
> >
> > Signed-off-by: Li kunyu <kunyu@nfschina.com>
> > ---
> > v2: Fix timestamp issues
> >
> > security/apparmor/file.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/security/apparmor/file.c b/security/apparmor/file.c
> > index 698b124e649f..12eafdf18fc0 100644
> > --- a/security/apparmor/file.c
> > +++ b/security/apparmor/file.c
> > @@ -264,7 +264,7 @@ int aa_path_perm(const char *op, struct aa_label *label,
> > {
> > struct aa_perms perms = {};
> > struct aa_profile *profile;
> > - char *buffer = NULL;
> > + char *buffer;
>
> this is okay
>
> > int error;
> > flags |= PATH_DELEGATE_DELETED | (S_ISDIR(cond->mode) ? PATH_IS_DIR :
> > @@ -412,7 +412,7 @@ int aa_path_link(struct aa_label *label, struct dentry *old_dentry,
> > d_backing_inode(old_dentry)->i_uid,
> > d_backing_inode(old_dentry)->i_mode
> > };
> > - char *buffer = NULL, *buffer2 = NULL;
> > + char *buffer, *buffer2;
>
> this can cause an oops if buffer2 allocation fails. There are a couple of ways I can
> see to fix this, do you want to take a crack at it.
>
>
> > struct aa_profile *profile;
> > int error;
I don't whether this kind of thing has become in vogue, but while indeed
the first case is okay right now, it becomes more likely that a future patch
to this function will inadvertently goto aa_put_buffer(buffer) before the
aa_get_buffer call. I would not have NACKed an original version of this fn
without the = NULL, but I'm not in favor of dropping it.
-serge
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-28 19:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-19 1:56 [PATCH v2] apparmor/file: Removing unnecessary initial values for variable pointers Li kunyu
2023-09-28 17:36 ` John Johansen
2023-09-28 19:35 ` Serge E. Hallyn
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).