lkml.org 
[lkml]   [2023]   [Feb]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] driver: core: Prevent NULL pointer dereference in device name functions
On Sun, Feb 12, 2023 at 11:04:41PM +0100, Alexander Sverdlin wrote:
> Prevent similar scenarios:
>
> Unable to handle kernel NULL pointer dereference at virtual address 00000038
> ...
> PC is at dev_driver_string+0x0/0x38

How did this "scenario" happen? What in-tree code caused this?

>
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
> ---
> drivers/base/core.c | 3 +++
> include/linux/device.h | 5 +++++
> 2 files changed, 8 insertions(+)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index a3e14143ec0c..4ff2ddea7c9b 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -2174,6 +2174,9 @@ const char *dev_driver_string(const struct device *dev)
> {
> struct device_driver *drv;
>
> + if (!dev)
> + return "<null>";
> +

None of these functions should be called with a NULL pointer as the
reference should have been properly gotten on them before calling these
functions. So let's fix up the callers please, something is really
wrong with them. Again, what in-tree code is causing this to happen?

thanks,

greg k-h

\
 
 \ /
  Last update: 2023-03-27 00:19    [W:0.068 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site