[-next] tcmu: fix error return code in tcmu_configure_device()
diff mbox

Message ID 1515669145-125352-1-git-send-email-weiyongjun1@huawei.com
State New, archived
Headers show

Commit Message

Wei Yongjun Jan. 11, 2018, 11:12 a.m. UTC
Fix to return error code -ENOMEM from the kzalloc() error handling
case instead of 0, as done elsewhere in this function.

Fixes: fabe6a59cc5a ("tcmu: allow max block and global max blocks to be settable")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/target/target_core_user.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)


--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Mike Christie Jan. 11, 2018, 5:10 p.m. UTC | #1
On 01/11/2018 05:12 AM, Wei Yongjun wrote:
> Fix to return error code -ENOMEM from the kzalloc() error handling
> case instead of 0, as done elsewhere in this function.
> 
> Fixes: fabe6a59cc5a ("tcmu: allow max block and global max blocks to be settable")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  drivers/target/target_core_user.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index bac08bc..2edd242 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -1705,8 +1705,10 @@ static int tcmu_configure_device(struct se_device *dev)
>  
>  	udev->data_bitmap = kzalloc(BITS_TO_LONGS(udev->max_blocks) *
>  				    sizeof(unsigned long), GFP_KERNEL);
> -	if (!udev->data_bitmap)
> +	if (!udev->data_bitmap) {
> +		ret = -ENOMEM;
>  		goto err_bitmap_alloc;
> +	}
>  
>  	udev->mb_addr = vzalloc(CMDR_SIZE);
>  	if (!udev->mb_addr) {
> 

Thanks.

Acked-by: Mike Christie <mchristi@redhat.com>
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nicholas A. Bellinger Jan. 13, 2018, 5:19 a.m. UTC | #2
On Thu, 2018-01-11 at 11:10 -0600, Mike Christie wrote:
> On 01/11/2018 05:12 AM, Wei Yongjun wrote:
> > Fix to return error code -ENOMEM from the kzalloc() error handling
> > case instead of 0, as done elsewhere in this function.
> > 
> > Fixes: fabe6a59cc5a ("tcmu: allow max block and global max blocks to be settable")
> > Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> > ---
> >  drivers/target/target_core_user.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> > index bac08bc..2edd242 100644
> > --- a/drivers/target/target_core_user.c
> > +++ b/drivers/target/target_core_user.c
> > @@ -1705,8 +1705,10 @@ static int tcmu_configure_device(struct se_device *dev)
> >  
> >  	udev->data_bitmap = kzalloc(BITS_TO_LONGS(udev->max_blocks) *
> >  				    sizeof(unsigned long), GFP_KERNEL);
> > -	if (!udev->data_bitmap)
> > +	if (!udev->data_bitmap) {
> > +		ret = -ENOMEM;
> >  		goto err_bitmap_alloc;
> > +	}
> >  
> >  	udev->mb_addr = vzalloc(CMDR_SIZE);
> >  	if (!udev->mb_addr) {
> > 
> 
> Thanks.
> 
> Acked-by: Mike Christie <mchristi@redhat.com>

Applied.  Thanks Wei + MNC.

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index bac08bc..2edd242 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1705,8 +1705,10 @@  static int tcmu_configure_device(struct se_device *dev)
 
 	udev->data_bitmap = kzalloc(BITS_TO_LONGS(udev->max_blocks) *
 				    sizeof(unsigned long), GFP_KERNEL);
-	if (!udev->data_bitmap)
+	if (!udev->data_bitmap) {
+		ret = -ENOMEM;
 		goto err_bitmap_alloc;
+	}
 
 	udev->mb_addr = vzalloc(CMDR_SIZE);
 	if (!udev->mb_addr) {