* [PATCH v2 0/3] platform/x86: dell_rbu: Packet data fixes @ 2025-05-22 20:09 Stuart Hayes 2025-05-22 20:09 ` [PATCH v2 1/3] platform/x86: dell_rbu: Fix sparse warning Stuart Hayes ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Stuart Hayes @ 2025-05-22 20:09 UTC (permalink / raw) To: linux-kernel, Hans de Goede, Ilpo Järvinen, platform-driver-x86 Cc: Stuart Hayes Make two fixes related to packet data and fix a sparse warning. Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com> --- v2: - Add "__must_hold" to create_packet to remove sparse warning. - Make struct packet_data_list static. Stuart Hayes (3): platform/x86: dell_rbu: Fix sparse warning platform/x86: dell_rbu: Fix list usage platform/x86: dell_rbu: Stop overwriting data buffer drivers/platform/x86/dell/dell_rbu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.47.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/3] platform/x86: dell_rbu: Fix sparse warning 2025-05-22 20:09 [PATCH v2 0/3] platform/x86: dell_rbu: Packet data fixes Stuart Hayes @ 2025-05-22 20:09 ` Stuart Hayes 2025-05-22 20:09 ` [PATCH v2 2/3] platform/x86: dell_rbu: Fix list usage Stuart Hayes 2025-05-22 20:09 ` [PATCH v2 3/3] platform/x86: dell_rbu: Stop overwriting data buffer Stuart Hayes 2 siblings, 0 replies; 6+ messages in thread From: Stuart Hayes @ 2025-05-22 20:09 UTC (permalink / raw) To: linux-kernel, Hans de Goede, Ilpo Järvinen, platform-driver-x86 Cc: Stuart Hayes Fix a sparse lock context warning. Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com> --- drivers/platform/x86/dell/dell_rbu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/dell/dell_rbu.c b/drivers/platform/x86/dell/dell_rbu.c index e30ca325938c..7b019fb72e86 100644 --- a/drivers/platform/x86/dell/dell_rbu.c +++ b/drivers/platform/x86/dell/dell_rbu.c @@ -91,7 +91,7 @@ static void init_packet_head(void) rbu_data.imagesize = 0; } -static int create_packet(void *data, size_t length) +static int create_packet(void *data, size_t length) __must_hold(&rbu_data.lock) { struct packet_data *newpacket; int ordernum = 0; -- 2.47.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/3] platform/x86: dell_rbu: Fix list usage 2025-05-22 20:09 [PATCH v2 0/3] platform/x86: dell_rbu: Packet data fixes Stuart Hayes 2025-05-22 20:09 ` [PATCH v2 1/3] platform/x86: dell_rbu: Fix sparse warning Stuart Hayes @ 2025-05-22 20:09 ` Stuart Hayes 2025-05-22 20:09 ` [PATCH v2 3/3] platform/x86: dell_rbu: Stop overwriting data buffer Stuart Hayes 2 siblings, 0 replies; 6+ messages in thread From: Stuart Hayes @ 2025-05-22 20:09 UTC (permalink / raw) To: linux-kernel, Hans de Goede, Ilpo Järvinen, platform-driver-x86 Cc: Stuart Hayes Stop using an entire struct packet_data just for the embedded list_head, and fix usage of that list_head. Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com> --- drivers/platform/x86/dell/dell_rbu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/dell/dell_rbu.c b/drivers/platform/x86/dell/dell_rbu.c index 7b019fb72e86..c03d4d55fcc1 100644 --- a/drivers/platform/x86/dell/dell_rbu.c +++ b/drivers/platform/x86/dell/dell_rbu.c @@ -77,14 +77,14 @@ struct packet_data { int ordernum; }; -static struct packet_data packet_data_head; +static struct list_head packet_data_list; static struct platform_device *rbu_device; static int context; static void init_packet_head(void) { - INIT_LIST_HEAD(&packet_data_head.list); + INIT_LIST_HEAD(&packet_data_list); rbu_data.packet_read_count = 0; rbu_data.num_packets = 0; rbu_data.packetsize = 0; @@ -183,7 +183,7 @@ static int create_packet(void *data, size_t length) __must_hold(&rbu_data.lock) /* initialize the newly created packet headers */ INIT_LIST_HEAD(&newpacket->list); - list_add_tail(&newpacket->list, &packet_data_head.list); + list_add_tail(&newpacket->list, &packet_data_list); memcpy(newpacket->data, data, length); @@ -292,7 +292,7 @@ static int packet_read_list(char *data, size_t * pread_length) remaining_bytes = *pread_length; bytes_read = rbu_data.packet_read_count; - list_for_each_entry(newpacket, (&packet_data_head.list)->next, list) { + list_for_each_entry(newpacket, &packet_data_list, list) { bytes_copied = do_packet_read(pdest, newpacket, remaining_bytes, bytes_read, &temp_count); remaining_bytes -= bytes_copied; @@ -315,7 +315,7 @@ static void packet_empty_list(void) { struct packet_data *newpacket, *tmp; - list_for_each_entry_safe(newpacket, tmp, (&packet_data_head.list)->next, list) { + list_for_each_entry_safe(newpacket, tmp, &packet_data_list, list) { list_del(&newpacket->list); /* -- 2.47.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 3/3] platform/x86: dell_rbu: Stop overwriting data buffer 2025-05-22 20:09 [PATCH v2 0/3] platform/x86: dell_rbu: Packet data fixes Stuart Hayes 2025-05-22 20:09 ` [PATCH v2 1/3] platform/x86: dell_rbu: Fix sparse warning Stuart Hayes 2025-05-22 20:09 ` [PATCH v2 2/3] platform/x86: dell_rbu: Fix list usage Stuart Hayes @ 2025-05-22 20:09 ` Stuart Hayes 2025-05-25 22:14 ` Ilpo Järvinen 2 siblings, 1 reply; 6+ messages in thread From: Stuart Hayes @ 2025-05-22 20:09 UTC (permalink / raw) To: linux-kernel, Hans de Goede, Ilpo Järvinen, platform-driver-x86 Cc: Stuart Hayes The dell_rbu driver will use memset to clear the data held by each packet when it is no longer needed (when the driver is unloaded, the packet size is changed, etc). The amount of memory that is cleared is (currently) the normal packet size. However, the last packet in the list may be smaller. Fix this to only clear the memory actually used by each packet, to prevent it from writing past the end of data buffer. Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com> --- drivers/platform/x86/dell/dell_rbu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/dell/dell_rbu.c b/drivers/platform/x86/dell/dell_rbu.c index c03d4d55fcc1..7d5b26735a20 100644 --- a/drivers/platform/x86/dell/dell_rbu.c +++ b/drivers/platform/x86/dell/dell_rbu.c @@ -322,7 +322,7 @@ static void packet_empty_list(void) * zero out the RBU packet memory before freeing * to make sure there are no stale RBU packets left in memory */ - memset(newpacket->data, 0, rbu_data.packetsize); + memset(newpacket->data, 0, newpacket->length); set_memory_wb((unsigned long)newpacket->data, 1 << newpacket->ordernum); free_pages((unsigned long) newpacket->data, -- 2.47.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 3/3] platform/x86: dell_rbu: Stop overwriting data buffer 2025-05-22 20:09 ` [PATCH v2 3/3] platform/x86: dell_rbu: Stop overwriting data buffer Stuart Hayes @ 2025-05-25 22:14 ` Ilpo Järvinen 2025-05-29 22:12 ` stuart hayes 0 siblings, 1 reply; 6+ messages in thread From: Ilpo Järvinen @ 2025-05-25 22:14 UTC (permalink / raw) To: Stuart Hayes; +Cc: LKML, Hans de Goede, platform-driver-x86 On Thu, 22 May 2025, Stuart Hayes wrote: > The dell_rbu driver will use memset to clear the data held by each packet Please add () after function names. > when it is no longer needed (when the driver is unloaded, the packet size > is changed, etc). > > The amount of memory that is cleared is (currently) the normal packet > size. However, the last packet in the list may be smaller. Fix this to One space is enough after . > only clear the memory actually used by each packet, to prevent it from > writing past the end of data buffer. > > Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com> Fixes tag? > --- > drivers/platform/x86/dell/dell_rbu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/platform/x86/dell/dell_rbu.c b/drivers/platform/x86/dell/dell_rbu.c > index c03d4d55fcc1..7d5b26735a20 100644 > --- a/drivers/platform/x86/dell/dell_rbu.c > +++ b/drivers/platform/x86/dell/dell_rbu.c > @@ -322,7 +322,7 @@ static void packet_empty_list(void) > * zero out the RBU packet memory before freeing > * to make sure there are no stale RBU packets left in memory > */ > - memset(newpacket->data, 0, rbu_data.packetsize); > + memset(newpacket->data, 0, newpacket->length); > set_memory_wb((unsigned long)newpacket->data, > 1 << newpacket->ordernum); > free_pages((unsigned long) newpacket->data, > -- i. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 3/3] platform/x86: dell_rbu: Stop overwriting data buffer 2025-05-25 22:14 ` Ilpo Järvinen @ 2025-05-29 22:12 ` stuart hayes 0 siblings, 0 replies; 6+ messages in thread From: stuart hayes @ 2025-05-29 22:12 UTC (permalink / raw) To: Ilpo Järvinen; +Cc: LKML, Hans de Goede, platform-driver-x86 On 5/25/2025 5:14 PM, Ilpo Järvinen wrote: > On Thu, 22 May 2025, Stuart Hayes wrote: > >> The dell_rbu driver will use memset to clear the data held by each packet > > Please add () after function names. > >> when it is no longer needed (when the driver is unloaded, the packet size >> is changed, etc). >> >> The amount of memory that is cleared is (currently) the normal packet >> size. However, the last packet in the list may be smaller. Fix this to > > One space is enough after . > >> only clear the memory actually used by each packet, to prevent it from >> writing past the end of data buffer. >> >> Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com> > > Fixes tag? > >> --- Thank you for reviewing this! I sent a new version (V3) with these fixes (and a module version bump). ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-05-29 22:12 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-05-22 20:09 [PATCH v2 0/3] platform/x86: dell_rbu: Packet data fixes Stuart Hayes 2025-05-22 20:09 ` [PATCH v2 1/3] platform/x86: dell_rbu: Fix sparse warning Stuart Hayes 2025-05-22 20:09 ` [PATCH v2 2/3] platform/x86: dell_rbu: Fix list usage Stuart Hayes 2025-05-22 20:09 ` [PATCH v2 3/3] platform/x86: dell_rbu: Stop overwriting data buffer Stuart Hayes 2025-05-25 22:14 ` Ilpo Järvinen 2025-05-29 22:12 ` stuart hayes
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).