Re: [Openipmi-developer] [PATCH] ipmi_ssif: Fix locking on probe error path

2019-08-24 Thread Corey Minyard
On Sat, Aug 24, 2019 at 05:51:47PM +0300, Dan Carpenter wrote:
> If the allocations failed then we returned with the lock held.  This
> patch moves the allocations infront of the locking.

This had already been fixed, but thanks for the heads up.

-corey

> 
> Fixes: 714acbc6cc39 ("ipmi_ssif: avoid registering duplicate ssif interface")
> Signed-off-by: Dan Carpenter 
> ---
>  drivers/char/ipmi/ipmi_ssif.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
> index 205726926bd3..9cf2efd33f19 100644
> --- a/drivers/char/ipmi/ipmi_ssif.c
> +++ b/drivers/char/ipmi/ipmi_ssif.c
> @@ -1683,7 +1683,6 @@ static int ssif_probe(struct i2c_client *client, const 
> struct i2c_device_id *id)
>   u8slave_addr = 0;
>   struct ssif_addr_info *addr_info = NULL;
>  
> - mutex_lock(_infos_mutex);
>   resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL);
>   if (!resp)
>   return -ENOMEM;
> @@ -1694,6 +1693,8 @@ static int ssif_probe(struct i2c_client *client, const 
> struct i2c_device_id *id)
>   return -ENOMEM;
>   }
>  
> + mutex_lock(_infos_mutex);
> +
>   if (!check_acpi(ssif_info, >dev)) {
>   addr_info = ssif_info_find(client->addr, client->adapter->name,
>  true);
> -- 
> 2.20.1
> 


___
Openipmi-developer mailing list
Openipmi-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openipmi-developer


[Openipmi-developer] [PATCH] ipmi_ssif: Fix locking on probe error path

2019-08-24 Thread Dan Carpenter
If the allocations failed then we returned with the lock held.  This
patch moves the allocations infront of the locking.

Fixes: 714acbc6cc39 ("ipmi_ssif: avoid registering duplicate ssif interface")
Signed-off-by: Dan Carpenter 
---
 drivers/char/ipmi/ipmi_ssif.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index 205726926bd3..9cf2efd33f19 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -1683,7 +1683,6 @@ static int ssif_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
u8slave_addr = 0;
struct ssif_addr_info *addr_info = NULL;
 
-   mutex_lock(_infos_mutex);
resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL);
if (!resp)
return -ENOMEM;
@@ -1694,6 +1693,8 @@ static int ssif_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
return -ENOMEM;
}
 
+   mutex_lock(_infos_mutex);
+
if (!check_acpi(ssif_info, >dev)) {
addr_info = ssif_info_find(client->addr, client->adapter->name,
   true);
-- 
2.20.1



___
Openipmi-developer mailing list
Openipmi-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openipmi-developer