]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
staging: nvec: Fix incorrect null termination of battery manufacturer
authorAlok Tiwari <alok.a.tiwari@oracle.com>
Sat, 19 Jul 2025 08:07:42 +0000 (01:07 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 24 Jul 2025 09:29:57 +0000 (11:29 +0200)
The battery manufacturer string was incorrectly null terminated using
bat_model instead of bat_manu. This could result in an unintended
write to the wrong field and potentially incorrect behavior.

fixe the issue by correctly null terminating the bat_manu string.

Fixes: 32890b983086 ("Staging: initial version of the nvec driver")
Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/20250719080755.3954373-1-alok.a.tiwari@oracle.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/nvec/nvec_power.c

index e0e67a3eb7222b38a45aa61fd23db0336d5b21a0..2faab9fdedef705bd8f2ba275b72abd44ba3f7d8 100644 (file)
@@ -194,7 +194,7 @@ static int nvec_power_bat_notifier(struct notifier_block *nb,
                break;
        case MANUFACTURER:
                memcpy(power->bat_manu, &res->plc, res->length - 2);
-               power->bat_model[res->length - 2] = '\0';
+               power->bat_manu[res->length - 2] = '\0';
                break;
        case MODEL:
                memcpy(power->bat_model, &res->plc, res->length - 2);