workqueue: simplify the apply_workqueue_attrs_locked()
authorwanghaibin <wanghaibin.wang@huawei.com>
Thu, 7 Jan 2016 12:38:59 +0000 (20:38 +0800)
committerTejun Heo <tj@kernel.org>
Thu, 7 Jan 2016 16:04:34 +0000 (11:04 -0500)
If the apply_wqattrs_prepare() returns NULL, it has already cleaned up
the related resources, so it can return directly and avoid calling the
clean up function again.

This doesn't introduce any functional changes.

Signed-off-by: wanghaibin <wanghaibin.wang@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/workqueue.c

index 1ecb588aae07e7e4806a309ee8352144dd14f90b..61a0264e28f9b5917c0e8a60bb9668b21e59c4b2 100644 (file)
@@ -3651,7 +3651,6 @@ static int apply_workqueue_attrs_locked(struct workqueue_struct *wq,
                                        const struct workqueue_attrs *attrs)
 {
        struct apply_wqattrs_ctx *ctx;
-       int ret = -ENOMEM;
 
        /* only unbound workqueues can change attributes */
        if (WARN_ON(!(wq->flags & WQ_UNBOUND)))
@@ -3662,16 +3661,14 @@ static int apply_workqueue_attrs_locked(struct workqueue_struct *wq,
                return -EINVAL;
 
        ctx = apply_wqattrs_prepare(wq, attrs);
+       if (!ctx)
+               return -ENOMEM;
 
        /* the ctx has been prepared successfully, let's commit it */
-       if (ctx) {
-               apply_wqattrs_commit(ctx);
-               ret = 0;
-       }
-
+       apply_wqattrs_commit(ctx);
        apply_wqattrs_cleanup(ctx);
 
-       return ret;
+       return 0;
 }
 
 /**