From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752630AbcGUNZJ (ORCPT ); Thu, 21 Jul 2016 09:25:09 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:51629 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752502AbcGUNZH (ORCPT ); Thu, 21 Jul 2016 09:25:07 -0400 Subject: Re: [PATCH v2] watchdog: ziirave_wdt: Add support to upload the firmware. To: Enric Balletbo Serra References: <1469010678-23058-1-git-send-email-enric.balletbo@collabora.com> <579044B8.3080508@roeck-us.net> Cc: Enric Balletbo i Serra , linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Wim Van Sebroeck , Martyn Welch From: Guenter Roeck Message-ID: <5790CD25.5030002@roeck-us.net> Date: Thu, 21 Jul 2016 06:24:53 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/21/2016 01:59 AM, Enric Balletbo Serra wrote: [ ... ] >>> >>> +static ssize_t ziirave_wdt_sysfs_store_firm(struct device *dev, >>> + struct device_attribute *attr, >>> + const char *buf, size_t count) >>> +{ >>> + struct i2c_client *client = to_i2c_client(dev->parent); >>> + struct ziirave_wdt_data *w_priv = i2c_get_clientdata(client); >>> + const struct firmware *fw; >>> + int err; >>> + >> >> >> What happens if this file is opened twice and written in parallel ? >> What if any >> other attribute is accessed while the firmware download is ongoing ? >> > > Good point. So you think I need to protect all with mutexes or there Yes, you have to protect any possible damaging parallel access with mutexes. > is another way? From a quick look on other drivers i didn't see this > kind of protection (something to look at in the future) > Really ? Can you point me to some examples ? This would be a bug. You'll have to fix the to get your patch accepted. Pointing to other examples with the same or a similar bug is not an argument. Thanks, Guenter