diff mbox

[v2,14/14] platform/x86: dell-wmi-smbios: clean up wmi descriptor check

Message ID 4178d2bdfc69c94fe4972fee7b97b08202890e66.1506451187.git.mario.limonciello@dell.com (mailing list archive)
State Superseded, archived
Delegated to: Darren Hart
Headers show

Commit Message

Limonciello, Mario Sept. 26, 2017, 6:50 p.m. UTC
Some cases the wrong type was used for errors and checks can be
done more cleanly.

Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
---
 drivers/platform/x86/dell-wmi-smbios.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Pali Rohár Sept. 26, 2017, 8:11 p.m. UTC | #1
On Tuesday 26 September 2017 20:50:12 Mario Limonciello wrote:
> +	if (strncmp(obj->string.pointer, "DELL WMI", 8) != 0)

Should not be this memcmp? IIRC we want to compare that buffer is equal 
to some bytes, right?
Limonciello, Mario Sept. 26, 2017, 8:19 p.m. UTC | #2
> -----Original Message-----

> From: Pali Rohár [mailto:pali.rohar@gmail.com]

> Sent: Tuesday, September 26, 2017 4:12 PM

> To: Limonciello, Mario <Mario_Limonciello@Dell.com>

> Cc: dvhart@infradead.org; Andy Shevchenko <andy.shevchenko@gmail.com>;

> LKML <linux-kernel@vger.kernel.org>; platform-driver-x86@vger.kernel.org;

> quasisec@google.com

> Subject: Re: [PATCH v2 14/14] platform/x86: dell-wmi-smbios: clean up wmi

> descriptor check

> 

> On Tuesday 26 September 2017 20:50:12 Mario Limonciello wrote:

> > +	if (strncmp(obj->string.pointer, "DELL WMI", 8) != 0)

> 

> Should not be this memcmp? IIRC we want to compare that buffer is equal

> to some bytes, right?

> 


It used to be comparing the bytes, but Andy S. thought this wasn't very clear.
That's why I adjusted it to compare to the strings that the bytes used instead.
diff mbox

Patch

diff --git a/drivers/platform/x86/dell-wmi-smbios.c b/drivers/platform/x86/dell-wmi-smbios.c
index 232a9dd482b1..290e9853818b 100644
--- a/drivers/platform/x86/dell-wmi-smbios.c
+++ b/drivers/platform/x86/dell-wmi-smbios.c
@@ -340,16 +340,16 @@  int dell_wmi_check_descriptor_buffer(struct wmi_device *wdev, u32 *version)
 	}
 	desc_buffer = (u32 *)obj->buffer.pointer;
 
-	if (desc_buffer[0] != 0x4C4C4544 && desc_buffer[1] != 0x494D5720)
-		dev_warn(&wdev->dev, "Dell descriptor buffer has invalid signature (%*ph)\n",
-			8, desc_buffer);
+	if (strncmp(obj->string.pointer, "DELL WMI", 8) != 0)
+		dev_warn(&wdev->dev, "Dell descriptor buffer has invalid signature (%8ph)\n",
+			desc_buffer);
 
 	if (desc_buffer[2] != 0 && desc_buffer[2] != 1)
-		dev_warn(&wdev->dev, "Dell descriptor buffer has unknown version (%d)\n",
+		dev_warn(&wdev->dev, "Dell descriptor buffer has unknown version (%u)\n",
 			desc_buffer[2]);
 
 	if (desc_buffer[3] != 4096)
-		dev_warn(&wdev->dev, "Dell descriptor buffer has invalid buffer length (%d)\n",
+		dev_warn(&wdev->dev, "Dell descriptor buffer has invalid buffer length (%u)\n",
 			desc_buffer[3]);
 
 	*version = desc_buffer[2];