* Re: [PATCH 2/3] drm/sysfs: Grab lock for edid/modes_show
[not found] <201509292218.OqhB7qjW%fengguang.wu@intel.com>
@ 2015-09-29 14:47 ` Julia Lawall
0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2015-09-29 14:47 UTC (permalink / raw)
Cc: Daniel Vetter, Intel Graphics Development, kbuild-all, DRI Development
Maybe line 294 should become an unlock and should be moved under 295?
julia
On Tue, 29 Sep 2015, kbuild test robot wrote:
> CC: kbuild-all@01.org
> In-Reply-To: <1443513993-5228-2-git-send-email-daniel.vetter@ffwll.ch>
> TO: Daniel Vetter <daniel.vetter@ffwll.ch>
> CC: DRI Development <dri-devel@lists.freedesktop.org>
> CC: Daniel Vetter <daniel.vetter@ffwll.ch>, Intel Graphics Development <intel-gfx@lists.freedesktop.org>
>
> Hi Daniel,
>
> [auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore]
>
> :::::: branch date: 2 hours ago
> :::::: commit date: 2 hours ago
>
> >> drivers/gpu/drm/drm_sysfs.c:277:1-11: second lock on line 294
> --
> >> drivers/gpu/drm/drm_sysfs.c:297:1-7: preceding lock on line 277
>
> git remote add linux-review https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git remote update linux-review
> git checkout 0a4b5f2c3380cb718d25f3ecf7af6cbbc4a7bced
> vim +277 drivers/gpu/drm/drm_sysfs.c
>
> f453ba04 Dave Airlie 2008-11-07 271 struct device *connector_dev = container_of(kobj, struct device, kobj);
> f453ba04 Dave Airlie 2008-11-07 272 struct drm_connector *connector = to_drm_connector(connector_dev);
> f453ba04 Dave Airlie 2008-11-07 273 unsigned char *edid;
> f453ba04 Dave Airlie 2008-11-07 274 size_t size;
> 0a4b5f2c Daniel Vetter 2015-09-29 275 ssize_t ret = 0;
> f453ba04 Dave Airlie 2008-11-07 276
> 0a4b5f2c Daniel Vetter 2015-09-29 @277 mutex_lock(&connector->dev->mode_config.mutex);
> f453ba04 Dave Airlie 2008-11-07 278 if (!connector->edid_blob_ptr)
> 0a4b5f2c Daniel Vetter 2015-09-29 279 goto unlock;
> f453ba04 Dave Airlie 2008-11-07 280
> f453ba04 Dave Airlie 2008-11-07 281 edid = connector->edid_blob_ptr->data;
> f453ba04 Dave Airlie 2008-11-07 282 size = connector->edid_blob_ptr->length;
> f453ba04 Dave Airlie 2008-11-07 283 if (!edid)
> 0a4b5f2c Daniel Vetter 2015-09-29 284 goto unlock;
> f453ba04 Dave Airlie 2008-11-07 285
> f453ba04 Dave Airlie 2008-11-07 286 if (off >= size)
> 0a4b5f2c Daniel Vetter 2015-09-29 287 goto unlock;
> f453ba04 Dave Airlie 2008-11-07 288
> f453ba04 Dave Airlie 2008-11-07 289 if (off + count > size)
> f453ba04 Dave Airlie 2008-11-07 290 count = size - off;
> f453ba04 Dave Airlie 2008-11-07 291 memcpy(buf, edid + off, count);
> f453ba04 Dave Airlie 2008-11-07 292
> 0a4b5f2c Daniel Vetter 2015-09-29 293 ret = count;
> 0a4b5f2c Daniel Vetter 2015-09-29 @294 mutex_lock(&connector->dev->mode_config.mutex);
> 0a4b5f2c Daniel Vetter 2015-09-29 295 unlock:
> 0a4b5f2c Daniel Vetter 2015-09-29 296
> 0a4b5f2c Daniel Vetter 2015-09-29 @297 return ret;
> f453ba04 Dave Airlie 2008-11-07 298 }
> f453ba04 Dave Airlie 2008-11-07 299
> f453ba04 Dave Airlie 2008-11-07 300 static ssize_t modes_show(struct device *device,
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/3] drm/sysfs: Grab lock for edid/modes_show
2015-09-29 8:06 ` [PATCH 1/3] drm/sysfs: Annote lockless show functions with READ_ONCE Daniel Vetter
@ 2015-09-29 8:06 ` Daniel Vetter
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Vetter @ 2015-09-29 8:06 UTC (permalink / raw)
To: DRI Development; +Cc: Daniel Vetter, Intel Graphics Development
We chase pointers/lists without taking the locks protecting them,
which isn't that good.
Fix it.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
drivers/gpu/drm/drm_sysfs.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 7506de0a75b4..d55e0d7a610d 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -261,23 +261,29 @@ static ssize_t edid_show(struct file *filp, struct kobject *kobj,
struct drm_connector *connector = to_drm_connector(connector_dev);
unsigned char *edid;
size_t size;
+ ssize_t ret = 0;
+ mutex_lock(&connector->dev->mode_config.mutex);
if (!connector->edid_blob_ptr)
- return 0;
+ goto unlock;
edid = connector->edid_blob_ptr->data;
size = connector->edid_blob_ptr->length;
if (!edid)
- return 0;
+ goto unlock;
if (off >= size)
- return 0;
+ goto unlock;
if (off + count > size)
count = size - off;
memcpy(buf, edid + off, count);
- return count;
+ ret = count;
+ mutex_lock(&connector->dev->mode_config.mutex);
+unlock:
+
+ return ret;
}
static ssize_t modes_show(struct device *device,
@@ -288,10 +294,12 @@ static ssize_t modes_show(struct device *device,
struct drm_display_mode *mode;
int written = 0;
+ mutex_lock(&connector->dev->mode_config.mutex);
list_for_each_entry(mode, &connector->modes, head) {
written += snprintf(buf + written, PAGE_SIZE - written, "%s\n",
mode->name);
}
+ mutex_unlock(&connector->dev->mode_config.mutex);
return written;
}
--
2.5.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-29 14:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <201509292218.OqhB7qjW%fengguang.wu@intel.com>
2015-09-29 14:47 ` [PATCH 2/3] drm/sysfs: Grab lock for edid/modes_show Julia Lawall
2015-09-29 7:37 [PATCH] drm: Fix locking for sysfs dpms file Daniel Vetter
2015-09-29 8:06 ` [PATCH 1/3] drm/sysfs: Annote lockless show functions with READ_ONCE Daniel Vetter
2015-09-29 8:06 ` [PATCH 2/3] drm/sysfs: Grab lock for edid/modes_show Daniel Vetter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).