]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform/x86/amd/hsmp: Change the error type
authorSuma Hegde <suma.hegde@amd.com>
Tue, 12 Nov 2024 12:04:50 +0000 (12:04 +0000)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Wed, 13 Nov 2024 13:36:33 +0000 (15:36 +0200)
When file is opened in WRITE only mode, then GET messages are not allowed
and when file is opened in READ only mode, SET messages are not allowed.
In these scenerios, return error EPERM to userspace instead of EINVAL.

Signed-off-by: Suma Hegde <suma.hegde@amd.com>
Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
Link: https://lore.kernel.org/r/20241112120450.2407125-2-suma.hegde@amd.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/amd/hsmp/hsmp.c

index ce91b2cefca2ccd531755e47c6207eebf0423686..f29dd93fbf0b495421f0891b81553edd856a336c 100644 (file)
@@ -262,7 +262,7 @@ long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
                 * Execute only set/configure commands
                 */
                if (hsmp_msg_desc_table[msg.msg_id].type != HSMP_SET)
-                       return -EINVAL;
+                       return -EPERM;
                break;
        case FMODE_READ:
                /*
@@ -270,7 +270,7 @@ long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
                 * Execute only get/monitor commands
                 */
                if (hsmp_msg_desc_table[msg.msg_id].type != HSMP_GET)
-                       return -EINVAL;
+                       return -EPERM;
                break;
        case FMODE_READ | FMODE_WRITE:
                /*
@@ -279,7 +279,7 @@ long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
                 */
                break;
        default:
-               return -EINVAL;
+               return -EPERM;
        }
 
        ret = hsmp_send_message(&msg);