On Thu, 2018-07-12 at 14:46 -0400, Tony Battersby wrote:
> Fix a minor memory leak when there is an error opening a /dev/sg device.
> 
> Signed-off-by: Tony Battersby <[email protected]>
> ---
> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index cd2fdac..2962a38 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -2185,6 +2185,7 @@ sg_add_sfp(Sg_device * sdp)
>       write_lock_irqsave(&sdp->sfd_lock, iflags);
>       if (atomic_read(&sdp->detaching)) {
>               write_unlock_irqrestore(&sdp->sfd_lock, iflags);
> +             kfree(sfp);
>               return ERR_PTR(-ENODEV);
>       }
>       list_add_tail(&sfp->sfd_siblings, &sdp->sfds);
> 

Reviewed-by: Ewan D. Milne <[email protected]>


Reply via email to