From: Sugar Zhang Date: Tue, 31 Mar 2015 07:19:59 +0000 (+0800) Subject: sofia3gr: ion: fix this issue, the reason is ion_import_dma_buf may be invoked concur... X-Git-Tag: firefly_0821_release~4158^2~167 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=firefly-linux-kernel-4.4.55.git;a=commitdiff_plain;h=8c5cdaefbe5c8ef191fbc25cc2d65a210ff0955a sofia3gr: ion: fix this issue, the reason is ion_import_dma_buf may be invoked concurrently. <4>[ 3123.242655] WARNING: CPU: 2 PID: 2648 at drivers/staging/android/ion/ion.c:512 ion_handle_add+0xb4/0xc0() <7>[ 3123.252189] ion_handle_add: buffer already found. <7>[ 3123.256694] Modules linked in: iwlmvm iwlwifi mac80211 cfg80211 compat <7>[ 3123.263195] CPU: 2 PID: 2648 Comm: TimedEventQueue Tainted: G W 3.14.0 #7 <7>[ 3123.270868] 00000000 00000000 9a3efd2c 80faf273 9a3efd6c 9a3efd5c 80935dc9 811d7fd3 <7>[ 3123.278405] 9a3efd88 00000a58 812208a0 00000200 80e128d4 80e128d4 8d4ae00c a8cd8600 <7>[ 3123.286065] a8cd8094 9a3efd74 80935e0e 00000009 9a3efd6c 811d7fd3 9a3efd88 9a3efd9c <7>[ 3123.293867] Call Trace: <7>[ 3123.296159] [<80faf273>] dump_stack+0x48/0x69 <7>[ 3123.300537] [<80935dc9>] warn_slowpath_common+0x79/0x90 <7>[ 3123.305913] [<80e128d4>] ? ion_handle_add+0xb4/0xc0 <7>[ 3123.310694] [<80e128d4>] ? ion_handle_add+0xb4/0xc0 <7>[ 3123.315703] [<80935e0e>] warn_slowpath_fmt+0x2e/0x30 <7>[ 3123.320586] [<80e128d4>] ion_handle_add+0xb4/0xc0 <7>[ 3123.325450] [<80e144cc>] ion_import_dma_buf+0x8c/0x110 <7>[ 3123.330490] [<80c517c4>] reg_init+0x364/0x7d0 <7>[ 3123.334975] [<80993363>] ? futex_wait+0x123/0x210 <7>[ 3123.339607] [<80992e0e>] ? get_futex_key+0x16e/0x1e0 <7>[ 3123.344692] [<8099308f>] ? futex_wake+0x5f/0x120 <7>[ 3123.349245] [<80c51e19>] vpu_service_ioctl+0x1e9/0x500 <7>[ 3123.354508] [<80994aec>] ? do_futex+0xec/0x8e0 <7>[ 3123.358885] [<80971080>] ? prepare_to_wait_event+0xc0/0xc0 <7>[ 3123.364503] [<80c51c30>] ? reg_init+0x7d0/0x7d0 <7>[ 3123.368955] [<80a22562>] do_vfs_ioctl+0x2d2/0x4c0 <7>[ 3123.373816] [<80b198ad>] ? inode_has_perm.isra.41+0x2d/0x40 <7>[ 3123.379278] [<80b199cf>] ? file_has_perm+0x7f/0x90 <7>[ 3123.384217] [<80b1a5f7>] ? selinux_file_ioctl+0x47/0xf0 <7>[ 3123.389351] [<80a227a8>] SyS_ioctl+0x58/0x80 <7>[ 3123.393754] [<80fb45e8>] syscall_call+0x7/0x7 <7>[ 3123.398043] [<80fb0000>] ? mmc_do_calc_max_discard+0xab/0xe4 <4>[ 3123.404220] ---[ end trace bd195cf65df321ce ]--- Signed-off-by: Sugar Zhang Signed-off-by: CMY --- diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 8508a40b19be..ebe4a3e6c4e4 100755 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -1519,13 +1519,13 @@ struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd) mutex_unlock(&client->lock); goto end; } - mutex_unlock(&client->lock); handle = ion_handle_create(client, buffer); - if (IS_ERR(handle)) + if (IS_ERR(handle)) { + mutex_unlock(&client->lock); goto end; + } - mutex_lock(&client->lock); ret = ion_handle_add(client, handle); mutex_unlock(&client->lock); if (ret) {