Message ID | 84b6170a1d3a692b53a40f795dd4f9a3052b8fe3.1506571188.git.mario.limonciello@dell.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Delegated to: | Darren Hart |
Headers | show |
On Thu, Sep 28, 2017 at 7:02 AM, Mario Limonciello <mario.limonciello@dell.com> wrote: > Some cases the wrong type was used for errors and checks can be > done more cleanly. Oops, I forgot about this patch, so, please, disregard my comment WRT to strncmp() use to the other patch. > Signed-off-by: Mario Limonciello <mario.limonciello@dell.com> > Reviewed-by: Edward O'Callaghan <quasisec@google.com> Btw, missed Suggested-by? > - 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); And as Darren pointed out, this fixes the logic bug as well.
> -----Original Message----- > From: Andy Shevchenko [mailto:andy.shevchenko@gmail.com] > Sent: Monday, October 2, 2017 8:16 AM > To: Limonciello, Mario <Mario_Limonciello@Dell.com> > Cc: dvhart@infradead.org; LKML <linux-kernel@vger.kernel.org>; Platform Driver > <platform-driver-x86@vger.kernel.org>; Andy Lutomirski <luto@kernel.org>; > quasisec@google.com; Pali Rohár <pali.rohar@gmail.com> > Subject: Re: [PATCH v3 8/8] platform/x86: dell-wmi-smbios: clean up wmi > descriptor check > > On Thu, Sep 28, 2017 at 7:02 AM, Mario Limonciello > <mario.limonciello@dell.com> wrote: > > Some cases the wrong type was used for errors and checks can be > > done more cleanly. > > Oops, I forgot about this patch, so, please, disregard my comment WRT > to strncmp() use to the other patch. > > > > Signed-off-by: Mario Limonciello <mario.limonciello@dell.com> > > Reviewed-by: Edward O'Callaghan <quasisec@google.com> > > Btw, missed Suggested-by? Yes sorry about that. I'll add that for when I get v4 out. > > > > - 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); > > And as Darren pointed out, this fixes the logic bug as well. > > -- > With Best Regards, > Andy Shevchenko
diff --git a/drivers/platform/x86/dell-smbios.c b/drivers/platform/x86/dell-smbios.c index ac176953e46e..d75b6971588e 100644 --- a/drivers/platform/x86/dell-smbios.c +++ b/drivers/platform/x86/dell-smbios.c @@ -346,16 +346,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];