Re: [PATCH] spmi: Add check for remove callback in spmi_drv_remove API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Dec 04, 2022 at 02:53:00PM +0530, Jishnu Prakash wrote:
> Add a check for remove callback presence before calling it for a
> spmi driver, to avoid NULL pointer dereference error if remove callback
> has not been specified for that SPMI driver.
> 
> Signed-off-by: Jishnu Prakash <quic_jprakash@xxxxxxxxxxx>
> ---
>  drivers/spmi/spmi.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spmi/spmi.c b/drivers/spmi/spmi.c
> index a456ce5..6b34356 100644
> --- a/drivers/spmi/spmi.c
> +++ b/drivers/spmi/spmi.c
> @@ -350,7 +350,8 @@ static void spmi_drv_remove(struct device *dev)
>  	const struct spmi_driver *sdrv = to_spmi_driver(dev->driver);
>  
>  	pm_runtime_get_sync(dev);
> -	sdrv->remove(to_spmi_device(dev));
> +	if (sdrv->remove)
> +		sdrv->remove(to_spmi_device(dev));
>  	pm_runtime_put_noidle(dev);
>  
>  	pm_runtime_disable(dev);

What in-kernel spmi driver does not have a remove function set that
requires this change?

thanks,

greg k-h



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux