Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib/bootconfig: use signed type for offset in xbc_init_node()

lib/bootconfig.c:415:32: warning: conversion to 'long unsigned int'
from 'long int' may change the sign of the result [-Wsign-conversion]

Pointer subtraction yields ptrdiff_t (signed), which was stored in
unsigned long. The original unsigned type implicitly caught a negative
offset (data < xbc_data) because the wrapped value would exceed
XBC_DATA_MAX. Make this intent explicit by using a signed long and
adding an offset < 0 check to the WARN_ON condition.

Link: https://lore.kernel.org/all/20260318155919.78168-12-objecting@objecting.org/

Signed-off-by: Josh Law <objecting@objecting.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

authored by

Josh Law and committed by
Masami Hiramatsu (Google)
0f219990 68f479de

+2 -2
+2 -2
lib/bootconfig.c
··· 412 412 413 413 static int __init xbc_init_node(struct xbc_node *node, char *data, uint16_t flag) 414 414 { 415 - unsigned long offset = data - xbc_data; 415 + long offset = data - xbc_data; 416 416 417 - if (WARN_ON(offset >= XBC_DATA_MAX)) 417 + if (WARN_ON(offset < 0 || offset >= XBC_DATA_MAX)) 418 418 return -EINVAL; 419 419 420 420 node->data = (uint16_t)offset | flag;