[PATCH] apparmor: Drop needless check in AppArmorSetMemoryLabel()

Michal Privoznik posted 1 patch 3 years, 5 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/8418e35d2f27429fa305f78e2c4a9a6d8b959e57.1607095863.git.mprivozn@redhat.com
src/security/security_apparmor.c | 3 ---
1 file changed, 3 deletions(-)
[PATCH] apparmor: Drop needless check in AppArmorSetMemoryLabel()
Posted by Michal Privoznik 3 years, 5 months ago
The AppArmorSetMemoryLabel() is a callback that is called from
qemuSecuritySetMemoryLabel() which never passes NULL as @mem.
Therefore, there is no need to check whether @mem is NULL. Also,
no other driver does that and just dereference it immediately.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/security/security_apparmor.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index eed66e460f..1b035cce2f 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -681,9 +681,6 @@ AppArmorSetMemoryLabel(virSecurityManagerPtr mgr,
                        virDomainDefPtr def,
                        virDomainMemoryDefPtr mem)
 {
-    if (mem == NULL)
-        return 0;
-
     switch (mem->model) {
     case VIR_DOMAIN_MEMORY_MODEL_NVDIMM:
         if (!virFileExists(mem->nvdimmPath)) {
-- 
2.26.2

Re: [PATCH] apparmor: Drop needless check in AppArmorSetMemoryLabel()
Posted by Peter Krempa 3 years, 5 months ago
On Fri, Dec 04, 2020 at 16:31:03 +0100, Michal Privoznik wrote:
> The AppArmorSetMemoryLabel() is a callback that is called from
> qemuSecuritySetMemoryLabel() which never passes NULL as @mem.
> Therefore, there is no need to check whether @mem is NULL. Also,
> no other driver does that and just dereference it immediately.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/security/security_apparmor.c | 3 ---
>  1 file changed, 3 deletions(-)

Reviewed-by: Peter Krempa <pkrempa@redhat.com>